Questions tagged [lua]

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

Filter by
Sorted by
Tagged with
0
votes
0answers
20 views

LuaLaTeX Element Ignore in PDF and Store in Variables

I have using luaxml-domobject to take XML in LuaLaTeX. I would like to store the XML contents in Global variable and will do Regular Expressions. In the below my example I no need to print ART-SUB-...
1
vote
1answer
39 views

LuaLaTeX Element with attribute values find

I have need to find <ELEMENT attr="A2"> and print in PDF. How to achieve this. My MWE is: \documentclass{article} \usepackage{luacode} \begin{luacode*} xml = require('luaxml-mod-xml') ...
1
vote
0answers
44 views

Define an incremental counter with Lua

I would like to receive a suggestion for this example. Really, it is more a question related to Lua scripting. Minimal working example \documentclass{beamer} \directlua{dofile("timer.lua")} ...
0
votes
0answers
32 views

Reading information from .bib file with lua? [duplicate]

I'm wondering if it's possible to access the information in a .bib file using Lua code in LuaTeX. Basically, I have a function where I'd like to be able to add idiosyncratic custom citation styles for ...
24
votes
1answer
985 views

What are some typical LuaTeX gotchas?

The interaction of TeX and Lua can be quite delicate at times. While the former has category codes and tokens, the latter has escape sequences and datatypes. Mixing the disparate concepts of these ...
0
votes
1answer
41 views

LuaLatex: use argument for \input, specification of lua, luatex and tex interaction

I want to process command line arguments directly for usage in lua code and subsequent latex. Looking for documentation I found no hints to tex-bindings for the \input command. In this sample case I ...
2
votes
1answer
108 views

MathML Format XML in Lua

I have successfully loaded XML in LuaLaTeX. But how to load MathML. Any Lua Modules are available? My LaTeX file: \documentclass{article} \usepackage{luacode} \begin{luacode*} xml = require('luaxml-...
0
votes
1answer
25 views

how to add newline when printing to console in luacode function?

I'd like to print to the console (not back to latex) from inside luacode function. But I am not able to figure how to do it. When I add \n it does not like it. I am using print from inside lua to ...
1
vote
1answer
57 views

trouble matching %s in LuaTeX argument containing LaTeX command

I hope I can communicate this clearly. I've been trying to pass an argument to a Lua function that contains LaTeX commands. Normally this works fine, but if Lua tries to match/sub %s within this ...
0
votes
0answers
36 views

luatex node library: replace glyph with hlist containing glyph

While trying to replace glyph node with a hlist containing the glyph I was expecting to see the same output on the line, but I see boxes overlap, and get a pdf backend warning. Here, the warning ...
0
votes
0answers
53 views

How can lua help class or package authors?

I am maintaining a rather simple class for internal company use for myself and some collegues. Mostly simple stuff like including the logo, setting the paper formats, adjust the colors, set headers ...
2
votes
1answer
65 views

Variable processing, lualatex or expl3, or something else?

I commonly find myself facing the same task of streamlining complex data entry for classes I write. I alway use the same front end. Data is entered and stored in variables, then a processing command ...
2
votes
1answer
46 views

make4ht: allowing the build process to continue when parsing fails

I use make4ht to produce html; part of the process is a custom build file that parses the HTML and does some checking/operations: mwe.tex \documentclass{article} \begin{document} test: $2^3$ ...
2
votes
1answer
52 views

Importing luaqd library in LuaTeX

I am looking for easy way to importing lqd or some other similar library in LuaTeX so that It can used in LaTeX. The lmapm library is wriiten by Luiz Figueiredo, one of the authors of the Lua ...
5
votes
2answers
1k views

Incorrect value of Pi in Lua after 16th Decimal Place

The following is the code. \documentclass{article} \usepackage{luacode} \begin{document} \luaexec{tex.sprint(string.format('\%.20f', math.pi))} \end{document} It gives the output as 3....
1
vote
1answer
73 views

Require gives error in lualatex in texlive 2020 and Ubuntu Bionic

I have tried many ways to include a module installed by luarocks in a tex file to be processed by lualatex, but all methods give me /texmf-dist/tex/luatex/lualibs/lualibs-basic-merged.lua:381: ...
1
vote
1answer
87 views

Setting Environment while defining complex numbers in LuaTeX

My question is inspired from this question that I asked earlier. Here is the code. \documentclass{article} \usepackage{parskip,luacode} \begin{luacode*} M = {} -- the module complex = {} -- ...
1
vote
1answer
99 views

Evaluating Mathematical Expressions in Lua

Here is the code. \documentclass{article} \begin{document} \directlua{tex.sprint(tostring(math.sin(math.pi)))} \\ \directlua{tex.sprint(tostring(math.tan(math.pi/2)))} \end{document} I am expecting ...
4
votes
1answer
91 views

Trouble while giving input from tex.sprint function to another function in LuaTeX

I have the set.lua file with the following code. local Set = {} --module local mt = {} --metatable function Set.new (l) local set = {} setmetatable(set, mt) for ...
2
votes
1answer
77 views

Error when Metatable is set for global environment in Lua LaTeX

I have the set.lua file with the following code. local Set = {} --module local mt = {} --metatable setmetatable(_G,{__index=function(t,k) return k end}) --some functions return Set ...
5
votes
1answer
128 views

Using unicode “combining right arrow above” to generate vector command in Plain LuaTeX

As Marcel Krüger has shown in his answer Using unicode "combining right arrow above" to generate vector command it is possible to use the “combining right arrow above” as the \vec command. ...
2
votes
1answer
176 views

How to draw graphs of standard functions using mpgraph?

Is it possible to draw graph of standard functions using mpgraph (probably using lua, mplib)? For example something like gdraw(sin(x)+cos(x)), gdraw(2x+3) and in general gdraw(f(x)) where f(x) is ...
4
votes
1answer
112 views

Using Lua functions with mplib and mpgraph

This question has reference to the question Error with Lua, Luamplib and Mpgraph I am trying to use lua functions inside mplib. The detailed code is here. \documentclass{article} \usepackage{luacode}...
4
votes
1answer
93 views

Error with Lua, Luamplib and Mpgraph

The following code works fine. \documentclass{article} \usepackage{luamplib} \begin{document} \begin{mplibcode} input graph ; beginfig(0) ; draw begingraph(5cm,3cm) gdraw (0,0) for x = 1 ...
1
vote
1answer
67 views

Pass a whole table built with datasetvariables to a Lua function

I am using ConTeXt to mark my pupils in a semi-automated way. My comments and grades are stored in dataset variable, as in the MWE below. I am trying to sum automatically points using a Lua function ...
2
votes
1answer
618 views

pdftexcmds error: wrong lua module

I just did a clean install from texlive, I updated every package with tlmgr and I get this error when trying to run lualatex: ! Package pdftexcmds Error: Wrong version of lua module. (pdftexcmds) ...
4
votes
1answer
127 views

transform a scientific notation to decimal notation with lua

The next code gives 5e-05 with \luaveclen{0.00003}{0.00004} but I need a decimal How to get a decimal notation ? \def\luaveclen#1#2{ \directlua{ x = #1; y = #2; r=(x*x+y*y)...
1
vote
0answers
124 views

ConTeXt command list

How can I get a “machine readable” version of the ConTeXt command list? Ideally, I would like to get a Lua table in some reasonable format, listing all commands and their main attributes (like ...
3
votes
1answer
94 views

Using Lua in tikzpicture

I am currently exploring ways to generate TikZ code using LuaTeX. Using the luacode* environment seems to be smooth sailing. But sometimes it seems to make more sense to just inject small fragments ...
2
votes
1answer
68 views

PythonTeX: Using LaTeX macros in pyblock

Is possible to use LaTeX macros in pythonTeX pyblock environment and use/store theyre output on python side of pythonTeX? Following MWE should completely illustrate my question: \documentclass[11pt]{...
3
votes
2answers
85 views

How can I use \n in \directlua{} to replace empty lines

Let’s assume I have a file file.txt containing This is a test and I want to replace the contents (from within TeX) with This is\par a test I tried to use Lua but stuck with the \n in the ...
9
votes
1answer
203 views

Calculating with \directlua in Plain LuaTeX

I have never used Lua before, so I have some questions about the calculations: How can avoid appending .0 if the result is an integer? How can I achieve that the right number of zeros is appended ...
5
votes
1answer
148 views

How to Set Lengths (Glue/Skips?, not Dimensions), in LuaTeX?

I am trying to define a length, (not a dimension)—using Lua. But, I am having trouble with the syntax. I think I am supposed to be using the same structures/prototypes as glue_spec in order to still ...
0
votes
1answer
85 views

Load font style of OpenType font in lualatex

I got some problems loading .otf fonts with fontspec in lualatex. What I don't get is the following: Let's suppose I have several .ttf font styles. Then I will just specify them succesively for my ...
1
vote
1answer
62 views

Lua, does tex.print only accumulate

I can either build the output first then use tex.print or I can use tex.print for each string. Is there a performance penalty? It's easier to use tex.print than having to build the string but if it ...
1
vote
1answer
84 views

How to correctly set x,y of nodes within a custom lua layout

I am trying to understand how I can place nodes within lua at correct x and y coordinates. I have this code mainly from the pgf/tikz manual: -- This is the file RectangleTreeLayout.lua local declare ...
15
votes
2answers
882 views

Different answers of calculations in LuaLaTeX on local computer, lua compiler and on overleaf

Here is the code. It makes use of the file matrix.lua available at the following link. https://github.com/davidm/lua-matrix/blob/master/lua/matrix.lua The following code is to be run by matrix.lua ...
3
votes
1answer
184 views

Lua package submission to ctan

I have created some useful stuff for Mathematics with lua. So far I have the following files. my package.sty file1.lua file2. lua readme documentation.tex documentation. pdf The read me file ...
1
vote
1answer
113 views

Nesting of functions not working in lualatex

Here is the code. It makes use of the file matrix.lua available at the following link. https://github.com/davidm/lua-matrix/blob/master/lua/matrix.lua \documentclass{article} \usepackage{luacode} \...
0
votes
1answer
95 views

Using output of one lua function as input of another function in tex file

The following is the code. \documentclass{article} \usepackage{luacode} \begin{document} \begin{luacode*} function string(x) tex.sprint(x) end function combine(x,y) tex.sprint(x.." "..y) end \end{...
4
votes
2answers
138 views

Bug in Lualatex: not printing characters from calculation

I have the following code \documentclass{article} \usepackage{luacode} \begin{document} \begin{luacode*} local matrix = require "matrix" local complex = require "complex" function cmatrix(n) return ...
2
votes
2answers
206 views

How to pass array of values in lualatex?

Here is code for matrix multiplication. \documentclass{article} \usepackage{luacode} \begin{luacode} function MatMul( m1, m2 ) if #m1[1] ~= #m2 then return nil end local ...
9
votes
1answer
305 views

Finding Greatest Common Divisor using LuaLatex

Here is my code to find Greatest Common Divisor of two positive integers. \documentclass{article} \usepackage{luacode} \begin{luacode} function gcd(a,b) if b ~= 0 then return gcd(b, a % ...
1
vote
0answers
64 views

TeX Live: “(lua): Not Enough Memory” | Chinese Fonts

I have a freshly installed and updated TeX Live system. I want to compile a simple LuaLaTeX document containing Chinese characters (see below, not a MWE, just for illustration). During the compilation ...
8
votes
3answers
462 views

Arithmetics in LuaLaTeX

I have the following code. \documentclass{article} \usepackage{luacode} \begin{luacode} function fact(n) if n == 0 then return 1 else tex.sprint ( n * fact(n - 1) ) ...
6
votes
3answers
371 views

Resources for learning Lua programming

I saw power of LuaLaTeX through several examples on the TeX Stack Exchange site. Could you suggest some books or other resources to learn Lua programming? I want to learn about variables, loops, ...
2
votes
1answer
198 views

Conditional string replacements in LuaLaTeX

I want to process whole tex file content with string replacements using lua. The following are the conditions F, G, H should be replaced by P, Q, R respectively. However if they aren't followed by a,...
5
votes
3answers
690 views

Auto replacement of characters

To make it very simple, I want to change the mapping of keyboard keys and unicode characters, but not by programming. I want to do it with LaTeX. eg. As suggested by @Ulrike and @Phelype I've edited ...
10
votes
1answer
170 views

How do I define a new TeX register with arguments in LuaTeX?

Some time ago I tried to implement the \pdfadjustinterwordglue from pdfTeX in LuaTeX using a callback. Getting the callback to work is pretty simple, but there is another major problem in the way ...
2
votes
1answer
61 views

How to make `kpse.find_file` aware of `\input@path` modifications?

I'm working on a \graphicspath like feature for GregorioTeX and having some problems making \input@path work with our Lua code. Basically, while \input@path works for \input statements, before we ...

1
2 3 4 5