Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [luacode]

A package to simplify inclusion of lua code in a LaTeX document

4
votes
1answer
113 views

Create a Table with Luatex

I want to make make a template table with parameters. I found different types of solutions but then I try to do some changes, it doesn't work anymore. I tried two different ways: First way \...
6
votes
2answers
102 views

Can luacode be used in the preamble of a standalone-type document?

I was trying to input/import a standalone document containing a tikz image, which was made using the help of luacode. I was able to compile the standalone document containing the image, however, ...
5
votes
1answer
70 views

token.set_macro: \directlua vs. luacode*

If I compile the following code with LuaLaTeX I get the word "RED" as output. The call of token.set_macro inside of luacode* seems to be noneffective. \listfiles \documentclass{minimal} \usepackage{...
3
votes
2answers
84 views

Collision of etoolbox and LuaLatex

I use a macro \mychoice{item a, item b, items c,…} that returns one of the items of the comma-separated-list determined by an external counter based on the \docsvlist macro from etoolbox. In simple ...
1
vote
1answer
37 views

Misplaced \tikzmark

In the next code, I hoped the tikzmark should be placed on the tabular black lines, but there is a drift. The main goal is to put a phantom tikz mark in each corner of each cell of a table. \...
3
votes
2answers
164 views

LuaLaTeX parse PDF for unencoded small string DeviceCMYK?

EDIT: It turns out that Lua is not needed. Since I call my TeX from script, the necessary investigation can be done directly, using findstr in Windows batch, or the equivalent in BASH. But that's ...
4
votes
0answers
106 views

Mixing expl3 and luacode

What do you think about mixing expl3 and luacode? Is this an "accepted approach" or rather a "bad practise" or something in between? Consider, for example, my previous question Nested splitting of a ...
0
votes
1answer
91 views

Generate a list of QR-code with lua

I want to generate a list of digit sequences, where a part of a sequence is a counter and another one is generated depending on this counter. My MnotWE \documentclass{book} \usepackage{luacode} \...
3
votes
1answer
784 views

Load fields from JSON file using LuaLatex

I want to load a lot of numbers in my document from a single JSON file that is returned from a simulation. To do that I so far followed this stackexchange answer but for multiple values I would have ...
2
votes
1answer
121 views

lstlisting environment inside luacode

I'd like to feed a lstlisting environment (from the listings package) with contents back to TeX from Lua, but the end of lstlisting is apparently not found. The same happens if lstlisting is replaced ...
0
votes
1answer
138 views

How to implement luabidi so that I can use luacode in XeLaTeX

I would like to use the following luacode (follow-up from this post): \usepackage{luacode} \begin{luacode*} function replace_punc ( buff ) if string.find ( buff , "\\gla" ) then buff = ...
9
votes
2answers
547 views

LuaTeX C API as Lua C API

I'm writing a Lua Module for LuaLaTeX. Does a LuaTeX C API exist? For example, how can I use the C version of tex.print into my C code? Thanks in advance
2
votes
1answer
138 views

LuaLaTeX: fonts.handlers.otf.addfeature kerning pairs with unexpected behaviour

So I tried to adapt this answer: https://tex.stackexchange.com/a/370469/75284 to all problematic neighbors of the narrow 1 and added the second group of kerning pairs, the ones that specify the ...
12
votes
3answers
565 views

LuaLaTeX: Change kerning around “1” to simulate proportional figures

I have the problem that both the original Helvetica and the Neue Helevetica font families by Linotype, in their OpenType versions, seem to not have proportional figures, only tabular figures, where ...
1
vote
1answer
265 views

LuaLaTeX — Attempt to index global 'luatexbase'

I'm working on a LuaLaTeX-Document project using my laptop and a desktop PC. The document contains a LuaLaTeX script to enable C-Style comments (link). However, while compilation works fine on my ...
2
votes
1answer
121 views

LuaLaTeX: compilation fails when sorting text using luacode

In this MWE, \RequirePackage{luatex85} \documentclass{elsarticle} \usepackage[tuenc]{fontspec} \usepackage{todonotes,etoolbox} \makeatletter \newcommand\@todonotes@owner{default} \define@key{...
2
votes
1answer
113 views

Is it possible be use directlua substitutions inside listings environment?

is it possible to insert a directlua substitution inside a listings environment? for example - \begin{luacode} a=math.random() b=math.random() \end{luacode} \begin{listings} if(\...
1
vote
2answers
192 views

Recognize custom syntax with luatex

I want my latex template to recognize the following Markdown syntax (Admonition): !!! note "My Note Title" This is a note with multible lines Not part of the note. These Admonition ...
2
votes
0answers
133 views

Filtering results of iterator from table in csv file

I am a Lua novice, and I would like to know if there is any way for an iterator to filter out or skip certain items in a table from a csv file. In particular, I would like for an iterator to be able ...
5
votes
1answer
119 views

lualatex-luatextra math mode issue

I'm new here (i.e., pardon my ignorance). But I've been tootling around the LuaLatex and I've come across some bizarre behavior. The following code \documentclass{article} \usepackage{luatextra} \...
2
votes
1answer
225 views

Execute luacode after \end{document} to rename pdf file after creation

I'm using toggle switches to create different outputs with a single tex-file. However my output PDF is always named after the producing tex-file e.g. luaexample.tex produces luaexample.pdf. Along ...
3
votes
1answer
1k views

Error message “invalid escape sequence near ”\%" when tex.sprint is inside a \chapter command

The error message "invalid escape sequence near "\%"" occurs only when a \luaexec tex.sprint is placed inside a \chapter command: why ? \documentclass{book} \usepackage{luacode} \begin{document} \...
4
votes
2answers
448 views

why luacode environments do not ignore lua comment — lines?

I do understand (a little) the difference between luacode and luacode* But I almost fell of my seat when something I wrote inside a commented line caused lualatex to scream at me. I changed luacode* ...
3
votes
1answer
629 views

How to use LaTeX commands in a luacode* environment?

How can one access LaTeX commands in the starred version of luacode environment? I am basically interested in using \ifdefined code below. For example, this works: \documentclass{article} \...
5
votes
1answer
246 views

Tikz, Lua, forget semicolon problem

In this M(n)WE, there in a loss of a semicolon. The tex.print part gives the good character chain it used directly in the new command, but as I want to use it in an external \draw, tikz claims for a ...
2
votes
1answer
70 views

Luacode in NewDocumentEnvironment problem

I want to put some systematic code at beginning and at the end of a luacode environment. Why this doesn't work. \documentclass{article} \usepackage{xparse,luacode} \NewDocumentEnvironment{LTG}{% ...
1
vote
2answers
92 views

Macro: compatibility of 1) Auto-colorization & 2) Auto-counter-and-title-to-label

This question is about asking to have the following 2 "workflows" (if you permit me to call them as such) to be able to coexist together in 1 Tex document: Workflow Auto-colorization (≅ User Mico's ...
1
vote
1answer
193 views

Integrating lua-generated Metapost graphics in Context

Normally we can integrate Metapost graphics in Context with the use of \startuseMPgraphic{id} and \useMPgraphic{id}. The idea is to define the graphics somewhere and use them somewhere else. However, ...
5
votes
1answer
259 views

Good lua code in .tex doesn't work in .sty?

I have some luacode in a .tex file that works fines, but does't in a .sty file -- with this error message : Runaway argument? ! File ended while scanning use of \luacode@grab@lines. \par <*...
1
vote
1answer
65 views

\luaexec inside \num causes errors

To me, an attractive feature in LuaTeX is the ability to effectively perform calculations directly in the document. Now say I want a command \proc that performs calculations and then formats the ...
16
votes
2answers
880 views

Is it possible to view the latex code after Lua expansion is made?

When using Lua code inside Latex file, where Lua code sends to Tex Latex code to insert into the document at the location the lua code is made, it will be useful to look at the content of Latex file (...