Questions tagged [lua]

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

Filter by
Sorted by
Tagged with
7 votes
2 answers
230 views

How to pass the the content from Lua function to a LaTeX3 token list (tl)?

I have a Lua function that generates LaTeX content (a string containing LaTeX commands like "\\textbf{foo}") and it can be successfully outputted with \lua_now:n and tex.print(). Now I'm ...
1 vote
1 answer
46 views

How to add support for another language (German) to the Words conversion in ConTeXt?

I would like to implement support for another language (German) for the conversion methods words and Words for converting numbers to words in ConTeXt. Having read the answers to this question I ...
  • 661
2 votes
0 answers
42 views

Lua substitution of double quotation mark

I'm playing with Lua substitutions and have realised I can't figure out how to escape quotation marks for double quotation marks (U+0022) and substitution code that works for every other character has ...
  • 414
4 votes
1 answer
129 views

Understanding implicit error on a recursive function

I was originally following the idea from Garrick Peschke To import all .tex files inside a folder, but I want my Lua function to also search inside subfolders. Unfortunately I can't make the Lua ...
  • 43
2 votes
1 answer
69 views

Dealing with curly braces in LuaLaTeX

I'm trying to generate a table with bolded text using a Lua snippet. Here's a minimal example. \documentclass{article} \usepackage{luacode} \begin{document} \begin{table}[h] \centering \begin{...
1 vote
2 answers
79 views

Automated age calculation by Lualatex

I came across an 11 year old query "Automated age calculation" about how to automate the calculation of a person's age. Something like: I'm \myage{day}{month}{year} years old. Another ...
  • 3,550
1 vote
1 answer
58 views

Passing tex value to a lua function

I have some limitation in my understanding of how to deal with tex and lua variable. I would like to pass the result of a Tex command in order to do some computation on it. Inside the lua function, ...
1 vote
0 answers
28 views

Generating table from lua with garamond font results in newline being unrecognized - kind of [duplicate]

This is really specific and really weird; I am trying to generate a longtable from Lua code, typset in the font GaramondNo8 (the exact one can be downloaded here). Weirdly, while the table is ...
0 votes
0 answers
35 views

Getting input filename in lualatex

As in title; I know status.filename gets the name of the exact file being currently compiled, but I want to know the one given as argument to lualatex. \jobname is also unhelpful because it may be ...
1 vote
1 answer
58 views

Parsing additional command-line arguments in luatex

I am trying to parse extra arguments given to lualatex in command line — e.g lualatex --jobname=out in.tex myarg. Though I could not find it in the docs, I discovered from this answer that I can use ...
1 vote
1 answer
82 views

Drawing 2d and 3d vectors using lua or luamplib in LaTeX

Here is the tikz code using which vectors can be drawn. \documentclass{article} \usepackage{tikz} \usepackage{tikz-3dplot} \usepackage{amsmath} \begin{document} \tdplotsetmaincoords{60}{120} \begin{...
  • 1,443
0 votes
0 answers
42 views

Extracting spatial metadata about \hboxes, \vboxes, glyphs, glues, etc

I have been using TeX for almost 10 years, but only very recently decided to learn more about what TeX really does under the hood. This is because I want to display LaTeX-rendered text and mathematics ...
  • 204
1 vote
1 answer
126 views

Enrich document preamble using pandoc

I use pandoc for generating a PDF file via lualatex from a markdown file. The document class scrartcl defines the command \publishers{}, which is employed in \maketitle. I would like to write a lua ...
  • 1,812
1 vote
0 answers
54 views

How to create an alphabetical attachment list that supports unicode characters?

I would like to be able to create a list of attachments similar to the list of figures or tables. However, since it makes little sense to sort the attachments by page number, I would like to sort them ...
  • 335
1 vote
1 answer
83 views

Origin of Lua Error

If a lualatex compilation breaks with/at this terminal output: (/usr/local/texlive/2022/texmf-dist/tex/generic/pgf/utilities/pgfkeysfiltered.c ode.tex))[\directlua]:1: attempt to call a nil value (...
  • 1,870
0 votes
1 answer
76 views

LuaTeX: How can I change the width (bounding box) of a letter?

I tried to adapt this solution by Marcel Krüger Fixing the position of math accents when using unicode-math in lualatex with a text font for letters and digits for changing the width (bounding box) of ...
1 vote
1 answer
43 views

commands defined in external file and imported by lua are not recognized

Suppose I have a file sourced.tex which defines a new command \MyCommand: \newcommand{\MyCommand}{Hello World} If I create a file main.tex and I source this file with \input, I'm able to use the ...
  • 1,460
0 votes
0 answers
385 views

(Not) finding Lua modules

I get an error that looks like my code doesn't find some Lua module(s) even from a Lua file in the same directory. git/uliska/diss/latexstuff/ulDissLua.lua:14: module './template-config.lua' not ...
  • 1,870
0 votes
1 answer
52 views

Detect draft mode from Lua in LuaLaTex

I'm working with a document for which I need to generate some data from a Lua script each time the PDF is produced. However, the generation of this data might be a slow, so I would like the script ...
  • 103
1 vote
1 answer
39 views

Pass string with escape characters and comma through xkeyval package while compiling the document with LuaLaTeX

The following is the code of the file temptest.sty \ProvidesPackage{temptest} \RequirePackage{amsmath,amssymb} \RequirePackage{xkeyval} \RequirePackage{luacode} \begin{luacode*} function myfunc(m,n) ...
  • 1,443
1 vote
2 answers
41 views

Alignment Gets changed in tabular environment on adding argument in lua function on compiling with LuaLaTeX

The following code works and gives expected output with expected alignment. \documentclass{article} \usepackage{luacode} \begin{luacode} function myfunc() str2=[[$1$ & $2$ & $3$ & $4$ &...
  • 1,443
3 votes
0 answers
84 views

Is it possible to generate LaTeX documents from within a lua interpreter?

I'm curious about the possibilities LuaTeX offers. I understand LuaTeX is a sort of unified API which allows you to hook into the TeX engine and benefit from some abstractions which would make the ...
  • 1,460
0 votes
1 answer
50 views

Issue with xkeyval package and special characters while compiling with LuaLaTeX

The following is the code of document myfile.tex. \documentclass{article} \usepackage{test} \begin{document} \begin{tabular}{|ccc|c|c|} \myPrint[trtext=Yes, fltext=No]{p,q,r}{stu} \\ \end{tabular} \...
  • 1,443
1 vote
0 answers
147 views

weird verbatim-like manual environment writing with luatex preprocessing

I'm currently trying to make my wrapper around tikzpicture while preserving the tikzexternalize functionality (see this post, this and this one for reference where some of my ideas came from): a real ...
  • 403
0 votes
2 answers
246 views

Pandoc convert specific parts of document

I have a markdown file of which I want to convert sometimes only specific parts, sometimes the whole document. I know about lua-filters and fenced div which I think is a possible approach, but how can ...
  • 21
0 votes
1 answer
38 views

macros avoid linebreak if macro expands to nothing

I know this one is quite similar to this post (from me). But even with using % all over the place and \ignorespaces there is still a linebreak. See my mwe: (main2.tex) \documentclass{article} \...
  • 403
0 votes
0 answers
60 views

I can't figure out tikz + gnuplot

I'm trying to output a gnuplot graph to tikz code. I tried using the set terminal lua tikz terminal in gnuplot. Gnuplot issued the corresponding code in the \begin{tikzpicture}[gnuplot] environment... ...
0 votes
0 answers
54 views

citeproc-lua prevent hyphenating the urls in references

I use citeproc-lua with texstudio in Windows 11. I have used apa csl style provided with the package citation-style-language as example here, but I have to use american-medical-association csl style ...
  • 65
1 vote
0 answers
91 views

citeproc-lua giving errors in luatex

I use windows 11. I don't konw how to use tex with command prompt. So, i use texstudio. I wanted to use cep referencing style in my report, which was not available in biblatex, bibtex. So, i installed ...
  • 65
1 vote
0 answers
54 views

Luaotfload: change kerning for many characters at once

How can I iterate over many characters? And how can I iterate over hexadecimal values? Not working MWE: \documentclass{article} \usepackage{unicode-math} \directlua{function W(s) return string.gsub(&...
2 votes
1 answer
58 views

How can I filter math with Lua toks?

Related to a previous question (How can I avoid TeX environment's when token filtering in LuaLaTeX?), I have been playing with creating a package using Lua to censor text (though it's at an early ...
0 votes
1 answer
90 views

gnuplot lua-tikz font to Arial

In gnuplot lua-tikz, I would like to change all letters that appear in a figure (including labels, tics numbers) to Arial. I tried several patterns as set term lua tikz tightboundingbox standalone ...
  • 101
2 votes
1 answer
58 views

How can I avoid TeX environment's when token filtering in LuaLaTeX?

This is a follow-up to: How can I exclude TeX macros when counting a string's characters in Lua? Thanks to @Henri Menke's excellent answer to that question (below), I know how to filter out macros ...
1 vote
2 answers
94 views

How can I exclude TeX macros when counting a string's characters in Lua?

A follow-up to my earlier question: Macro to replace text with random string of same length Thanks to the answer of @Mico, we now have a macro in Lua to replace a UTF-8 String with random characters. ...
2 votes
1 answer
220 views

Macro to replace text with random string of same length

I am playing with LuaLaTeX substitutions, trying to find a way to replace a string within a macro with random characters of the same length. The chickenize package offers the randomchars function ...
3 votes
1 answer
442 views

Minimal Testing Environment For LuaMetaTeX

The new LuaMetaTeX typesetting engine praises itself as being "lean and mean", but the ConTeXt package that it comes shipped with is actually pretty obese (around 270 MiB when installed). To ...
  • 49
1 vote
1 answer
86 views

Strange interaction between fontspec and lua

I noticed a strange interaction between the fontspec package and lua code. I have been using for some time a lua code found on this site that prevents words composed of a single letter ("a", ...
  • 397
0 votes
0 answers
55 views

textcolor inside bookdown math blocks

I am trying to get text coloring to work inside tex/math blocks. The code I inherited in latex is \[ H_0: b = \textcolor{orange}{0} \] This works fine for pdf but not for html. I have then read https:...
1 vote
2 answers
171 views

Printing Hostname in Lua

Related to How to detect and condition based on hostname . Answer in next post.
  • 3,477
1 vote
0 answers
80 views

A command call implemented in C, called from TeX via Lua. Why is it hanging?

The following C code (popen3luatex.c) implements a command call at the C level. This can be called from LuaTeX using the LaTeX file popen3luatex.tex, below popen3luatex.c. I've written little C code ...
  • 7,506
1 vote
1 answer
131 views

pgfplots contour lua with data in external file

i am working on a lot of measured data stored in a file, which i want to visualize with a contour plot. There I have coordinates x and y and a value z as function of x and y, which should be used to ...
2 votes
1 answer
71 views

LuaLaTeX code should generate an error, yet doesn't

I'm trying to learn a bit more about LuaLaTeX and came across this introduction. The author claims that the following code does not work: % this code will not work \directlua{ tex.print("\\...
  • 1,460
0 votes
1 answer
96 views

LuaLaTeX full font embedding + eforms package

i tried fully embedding a font using directives from How can I verify that the fonts are all embedded in my LuaLatex document? [1], using font BlackChancery from https://www.1001fonts.com/...
  • 1
1 vote
1 answer
123 views

LuaTeX compiling

May someone can explain me how to compile the LuaTeX source files available here : http://michel.quercia.free.fr/cours-MP.tgz together with the macro's files http://michel.quercia.free.fr/montchapet....
  • 536
1 vote
1 answer
133 views

lualatex luasec/luasocket

I hope this isn't frustrating since there are already other posts regarding a similar question, but somehow nothing I read so far works. As I'm under Arch Linux, I installed lua and luarocks via ...
  • 403
0 votes
1 answer
120 views

How can I use Lua's string.len() inside a metapost function?

I am designing pseudo-crosswords for my pupils exercices with the following macro: \startMPinclusions % could'nt achieve using the word string length as a first parameter vardef MotMystere (expr ...
  • 2,992
3 votes
1 answer
278 views

Lua - automatically turn - into -- if between two numbers

I've repeatedly read that Lua can do some cool under-the-hood things to TeX. One thing that comes to mind: I have a rather forgetful coworker who always used a hyphen instead of en-dash between two ...
3 votes
1 answer
95 views

Different output in Lua and LuaLaTeX

I'm using TeX Live 2020 (with LuaLaTeX 1.12.0) and Lua 5.3. When I compile the following .tex file using lualatex --shell-escape the content of the resulting .pdf is a. \documentclass{article} \...
1 vote
1 answer
60 views

Help on specific Latex command referencing Lua functions to be written with Lua

Today I write the following code snippet in a latex file and what I want to achieve works well : \draw [dotted] (\ordinateOnTimeAxis{-1500}, 2 * \laneHeight) -- (\ordinateOnTimeAxis{-1500}, 2 * \...
0 votes
0 answers
69 views

Unable to read a 'second' json file from inside a 'for' loop (Lua+Latex)

I'm looping through a json file and displaying content in the format below: Zone 1 Projection(Main.tex) Grat Table(gratsection.tex) Zone 2 Projection (Main.tex) Grat table (gratsection....
  • 37

1
2 3 4 5
7