Questions tagged [lua]

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

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

Luacode with several .tex files

I wrote some luacode in my main.tex and I'm a adding several other files due to \input{code.tex} I already asked this question here and it works on a standalone environment but not in my case. I can't ...
4
votes
1answer
85 views

Plotting function defined with Lua doesn't do anything

hopefully you can help me. I tried to plot a function with Tikz and Lua in the following way \documentclass[14pt]{book} \usepackage{marginnote} \usepackage{amsmath} \usepackage{multicol} \usepackage{...
0
votes
1answer
40 views

Syntax error in LuaLaTeX \directlua code

I have the below document that I try to compile with LuaLaTex (using the MiKTeX package). \documentclass{article} \usepackage{pgfplots} \pgfplotsset{compat=newest} \begin{document} \expandafter\...
0
votes
1answer
77 views

Lua Multiple for-loop statement

My XML Look is: <contrib-group content-type="all"> <contrib contrib-type="author"><name><surname>Bronnikov</surname><given-names>Kirill A<...
1
vote
0answers
48 views

how to find any values include special characters using lua regex

local tex = '\\authors{\\author[]{{Surname} {FirstName}\\textsuperscript{\\hyperref[{article-id-affiliationnumber1}]}{{\\textsuperscript{,{\\textcolor{blue}{article-id-affiliationnumber2}}}}}{{\\...
2
votes
1answer
69 views

LuaTeX: lua best coding practices

What are some of the best coding practices to follow when splitting and loading lua code from multiple external lua files, and dealing with lua code from other lualatex packages. This thought comes to ...
1
vote
1answer
71 views

LuaTeX node library: Vertical glue/kern does not work in manually made nodelist, what is missing?

This is a LuaTeX node-library/ node-list question. In the following code, I am trying to typeset a manually crafted nodelist. To add a line break, I add a penalty node, and that works fine (i.e. the ...
0
votes
0answers
25 views

font substitute is not working in lualatex for missing glyphs with another fonts

I have refered this link: Automatically substitute missing glyph with another in LuaLaTeX My LaTeX MWE IS: \documentclass{article} \usepackage[no-math]{fontspec} \directlua{ fonts.handlers.otf....
0
votes
1answer
32 views

Lua OR find and Replace

My LaTeX-out.tex TeX Code is (single line): \begin{align*}\alpha + \beta = \gamma\end{align*} Some text here. \begin{align*}\sum^{k}_{i=1} \iota \end{align*} and so on the text. \begin{...
0
votes
1answer
114 views

Translate TOC data to a Lua data-structure, and create custom table of content style

Given nested loops & data-structures are more elegant in Lua (than in TeX), I think plurality of table of contents style would be easier to write in Lua. For that to work, two things would be ...
0
votes
1answer
57 views

tex.sprint in LuaLaTeX

I would like to print text as per XML file. But when using tex.sprint enter mark is removed and all the text are displayed in single line in PDF. How do avoid this? My ds.tex file is \documentclass{...
0
votes
1answer
43 views

To Remove Enter marks (\n) in Lua

I have using LuaLaTeX Version : 1.12.0 and i have converting XML to LaTeX using Lua Script. I have need to remove enter marks in Lua Scripts. How to achieve this. \documentclass{article} \begin{...
1
vote
1answer
75 views

How to generate a centered and captioned TikZ figure in a .docx file that has been converted from .tex with pandoc?

Recently, I have been having some issues with TikZ in LaTeX. I want to convert my PhD dissertation, written in LaTeX, to .docx using pandoc. I am able to use lua filters to have pandoc convert TikZ ...
0
votes
2answers
56 views

Global Regular Expression in Lua Script

I have the below LaTeX coding in whole my document and want to do convert globally: \author{Bronnikov Kirill A{$^{1}$}{$^{2}$}{$^{3}$}} \author{Santos N O{$^{4}$}{$^{5}$}} \author{Wang Anzhong{$^{6}$...
0
votes
0answers
46 views

Lua Output Store in Separate Filename

I have used Regular Expression in Lua Script. After Conversion i would like to store the updation in separate file (ex: output.tex). How to achive this? My Lua Script is: local s = {} local ...
0
votes
1answer
48 views

Lua Script Output separate extra lines

My Input Latex: \documentclass{article} \usepackage{latexsym,amsmath,amssymb,amscd} \begin{document} \title{title} \author{author} \maketitle In this article we denote \begin{equation} \nu:=\frac{1}{...
0
votes
1answer
39 views

enumerate item showing errors in tex4ht

The below LaTeX enumerate list and after end{equation}\\ showing errors in tex4ht. How do solve this? I know to solve this errors through Lua Script. But i would like to know how to fix this type of ...
3
votes
0answers
61 views

How to prevent Lua-based macros from acting on nested macro names in ConTeXt?

I have two Lua functions that manipulate their arguments in different ways, and two new ConTeXt macros defined to let me use them. I tried to nest them together, but they seem to also be consuming and ...
2
votes
1answer
86 views

LuaTeX: Is there a way to define new named tex box purely on lua side (with desired checks)?

So far in my dealings with named tex boxes in luatex, I am able to set/get/copy its contents in lua code, but don't know how define new tex box in lua. The manual doesn't have a method explicitly ...
1
vote
0answers
87 views

LuaTeX: UTF-8 character extraction, is one way more accurate and/or preferable than another

While experimenting ways to extract UTF-8 character strings from TeX boxes, I found a post from user micahl-h21 here: UTF-8 text extraction. After looking at the way glyph data is stored in the ...
1
vote
0answers
40 views

LuaTeX - printing string literal producing strange dots

When I try to print a literal string with LuaTeX, these strange dots appear. Does anyone know why? Any suggestions to work around this? I was thinking of parsing the literal string line by line and ...
0
votes
0answers
73 views

LuaLatex , how put glyph freely

Lua are incredible engine. I have a font in ttf and I would put a specific glyph in a specific place. For example I create a logo. I need to put second version of 'a' in (x,y)=(12pt,30pt) from left ...
1
vote
1answer
55 views

passing a ConTeXt reference `(context.currentstructurereference)` to a lua function

I'd like to pass some ConTeXt references to a Lua function. Like in the following MWE, the idea is to have tables name passed to a function via context.currentstructurereference. The MWE fails to ...
1
vote
0answers
63 views

Lua function that replaces strings, but ignores spaces and TeX comments

I would like a Lua function for LuaTeX, called replaceButIgnoreSpacesAndComments (<string>, <what to replace>, <what to replace it by>) It is supposed to work like a string ...
1
vote
1answer
67 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') ...
2
votes
0answers
86 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
33 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 ...
28
votes
1answer
1k 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
76 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
156 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
32 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
62 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
51 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
62 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
83 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 ...
3
votes
1answer
86 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
58 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....
2
votes
1answer
180 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
90 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
144 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
102 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
92 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
171 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
229 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
130 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
105 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
70 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
700 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
226 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
2 3 4 5