Podcast #128: We chat with Kent C Dodds about why he loves React and discuss what life was like in the dark days before Git. Listen now.

Questions tagged [lua]

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

Filter by
Sorted by
Tagged with
1
vote
0answers
35 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
51 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
37 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
48 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
117 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
98 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
60 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
49 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
47 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
836 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
159 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
77 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
54 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
125 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
108 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
221 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
43 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 ...
7
votes
3answers
423 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
191 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, ...
1
vote
1answer
105 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
613 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
128 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
44 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 ...
0
votes
1answer
53 views

Can we draw tikz node with lua node this way?

I've found this example of using lua node. To output Va they've: \documentclass{minimal} \begin{document} \directlua{ local g1 = node.new("glyph") g1.font = font.current() g1....
1
vote
1answer
44 views

Insert something when *not* before a page break

I've tried to find a solution but obviously the right search phrases escape me ... I need to insert something into the document which will be suppressed if it would be followed by a page break. For ...
1
vote
1answer
124 views

How to draw network diagrams with lua and tikz?

I was reading this article on drawing with lua and tikz. On page 45 of the article, the author's given an example code demonstrating the way to do so. Here's his lua code: -- File SimpleDemo.lua ...
3
votes
1answer
192 views

Formatting table with a lua for loop

I was trying to get a table like this 1 2 3 4 5 6 7 8 9 10 with this function function myTable() t = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10} for k = 1, #t do if k == 1 then ...
2
votes
1answer
189 views

What is in `tex.print` or `tex.sprint`?

In an external file, I've put these 3 lines in a .lua file: function texTest(name) x = tex.print("Hello " .. name) end and when I call it from .tex file, it gets interpreted properly. Out of ...
2
votes
0answers
96 views

can one write tikz in lua code directly?

Sorry if this question sounds basic and naive for the experts, but something I wondered about for sometime. Since tikz itself is implemented in lua interviews/2015-till-tantau Then why can't one ...
0
votes
0answers
47 views

Preparing a latex installer to ship the reporting system

I have prepared a simple report making system that uses Latex to prepare all the reports. It is a simple system that prepares a 15 page report by reading a CSV file. I want to ship the system. I don'...
4
votes
3answers
120 views

Transforming a statement into a mathematical expression

Is there a way, where I could automatically transform a string (using a command) like: (1/SF) * (MDD\_a) * (1/LDD\_b) * (MBS\_b) * (1/SSA\_ab) into a mathematical expression like: $(\frac{1}{SF}) * ...
0
votes
0answers
100 views

Getting cross references for the total pages correct the first time

In order to have a footer at each page that displays the current page number with the total number of pages (Eg.,4 of 12), I used lastpage package and placed the statement: \rfoot{\thepage\ of \...
0
votes
1answer
30 views

Getting error undefined controlled sequence when trying to make a function of module

In the following code, the function named json_parser is meant to parse the JSON. I had initially kept this function as a separate module named json.lua and required it using: local json = require("...
0
votes
1answer
53 views

Getting Missing number, treated as zero error when trying to fit table in the document

While trying to dynamically render a table, it gets out of the document generated and looks as follows: To avoid this, I followed the steps mentioned in: SO Post - 1, which uses tabularx SO Post - 2,...
3
votes
0answers
126 views

Reducing the document preparation time with lualatex [closed]

I am trying to render a document that is around 2300 pages from a JSON file using lualatex. It takes around 32 seconds to create a document. The document is a series of tables and paragraphs. I think ...
0
votes
1answer
79 views

Saving all the latex to a file and then render reading from the file

I am rendering Latex that spawns ~2600 pages. The document is rendered from a JSON using Lua. It takes around 32 seconds to prepare the document of ~2600 pages. To verify, if there is a difference in ...
1
vote
0answers
27 views

How can you change the appearance of a line (edge) with a tikz graph drawing algorithm written in Lua?

In my graph drawing algorithm (written in Lua for LuaLaTeX), I'd like to change a solid line to a dashed line. I use a Digraph with some vertices and arcs between them. On page 499 of the Tikz & ...
1
vote
1answer
144 views

LuaLaTeX: How to correctly resolve absolute path with \directlua on Windows

I need to resolve absolute path to fonts: \setmainjfont[ Path = \currfileabsdir, UprightFont = fonts/HGS_Mincho/HGRMB.ttc, BoldFont = fonts/HGS_Mincho/HGRME.ttc ]{HGS ...
2
votes
1answer
110 views

Using ODT styles in a reference template to format make4ht

Following my recent question Customizing ODT output from mk4ht oolatex and a improved process alternative described here: Use ODT Template for make4ht (which makes use of direct formatting by using ...
6
votes
0answers
239 views

Convert all all-caps words to small caps #2

A question very similar to mine was asked before, but I assume that there are others with the same issue and that there are other solutions. I know several academic publishers that don't like ...
1
vote
0answers
89 views

Can't execute jar from directory with umlaut

Okay so this is quite an exotic question and I am unsure whether it really fits on this page. But as it involves LaTeX I'll post it here. I have written a Java program that I am calling from inside ...
0
votes
0answers
90 views

Custom Lua feature for CID-keyed font

fonts.handlers.otf.addfeature in luaotfload can be used to create custom features for fonts. The unicode values of glyphs can be used for CID fonts in the same way as for GID fonts, but some fonts ...
1
vote
1answer
109 views

LuaLaTeX set a path in lua

I have defined a command \newcommand{\mypath}{/Documents/Myfile/additionalresources/} that contains the path to some external files that I need in my main file. I need to use the \mypath command to ...
2
votes
1answer
369 views

Collect numbers a,b and c from equation $ax^2+bx+c=0$ with lpeg (luatex)

This is my first attempt to create macro with luatex. the macro \solveq to solve quadratic equation ax^2+bx+c=0 here my code \documentclass[12pt]{article} \usepackage{amssymb} \usepackage{luacode} ...
4
votes
2answers
112 views

Insert LaTeX code at line break

Is there a way to insert arbitrary (La)TeX-code at the line break of a typeset line? I am aware that this isn't really possible with (La)TeX as such. But looking at all the interesting chickenize-...
2
votes
0answers
132 views

Lua Table or XML as Bibliography File in LuaLaTeX

According to the ConTeXt Wiki in ConTeXt you can use the bibtex format for bibliographies but are not limited to that filetype. Since lua and XML are a little more universal but i can‘t (yet) switch ...
2
votes
0answers
121 views

Set global non-ligature kerning with selnolig

Similar to this question I want to use selnolig but I don't like the fact that in words containing fl without ligature these two letters are too close together. Like in Mico's answer I want to use ...
1
vote
1answer
81 views

TeXShop console (not log) contains entire LuaLaTeX file

I tried the example of "von" in the post Is direct utf8 input of combining diacritics in math mode possible with lualatex? regarding the use of a Lua script to allow TeX commands for combining ...
6
votes
1answer
141 views

Implement a job queue in LuaLaTeX

I have a project depending on LuaLaTeX where the main document first generates one or more intermediate .tex files and then invokes lualatex in a loop to generate the final PDF results. This can ...
4
votes
1answer
64 views

Setting page attributes of every page in a generated ConTeXt file

I'm trying to inject page metadata into a PDF generated with ConTeXt so that the pages have their tabbing order set to use the document structure (for accessibility checks). Currently, I can inject ...