The Stack Overflow podcast is back! Listen to an interview with our new CEO.

Questions tagged [lua]

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

Filter by
Sorted by
Tagged with
5
votes
1answer
94 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
50 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
48 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
42 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
826 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
157 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
74 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
51 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
120 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
101 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
203 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
40 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
411 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
171 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
84 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
604 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
120 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
43 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
43 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
43 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
110 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
171 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
174 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
87 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
46 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
113 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
94 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
27 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
49 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
121 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
71 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
24 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
123 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
106 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
235 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
84 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
103 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
361 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
109 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
130 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
77 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
137 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 ...
3
votes
2answers
97 views

Included lilypond files being processed by lualatex can't contain % symbol comments

My MWE below shows two files working together to create a document containing music using the lyluatex package. Unfortunately, I've observed that if I add any comments to the contents anywhere in the ...
0
votes
1answer
52 views

How to integrate xkeyval keys with Lua code

I am currently maintaining a template that uses directlua to compute a value based on a number of parameters defined as command keys with keyval. As it stands, it compiles correctly. However, when I ...
7
votes
4answers
337 views

How can I retrieve \thepage (or detect a page change) from Lua in LuaTeX?

I am writing (contributing to) a LuaLaTeX package where a Lua function is used to generate images that are inserted in the LaTeX document. One piece of information we need is the current page number ...
2
votes
1answer
480 views

LuaTeX error: LuaTeXbase-loader.sty

I am trying to edit my old CV with modernCV in Linux. Some missing styles and classes are not installed automatically -- so I now must try to do this manually. Since the popular package source ctan....
5
votes
1answer
145 views

Strange ConTeXt fail to load pgf.gd.control

I'm playing with PGF's (algorithmic) graph drawing, which relies on Lua internally. I have no problems with LaTeX, but ConTeXt fails to load the package. For the simple document: \usemodule[tikz] \...