Skip to main content

Questions tagged [directlua]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
2 votes
1 answer
79 views

Define strings representing macros in lualatex

I am using trying to define a variable in LuaLaTeX which holds a string representing a macro. The idea is (eventually) to pass that string to a tex.print and have the macro called. For example: \...
Nate Ackerman's user avatar
0 votes
0 answers
56 views

Compiling multi-script unicode LaTeX documents

I'm trying to write a latex document that supports arbitrary utf-8 encoded scripts. This is turning out to be surprisingly difficult. A key point is that I want to get this working without specifying ...
ketil's user avatar
  • 101
4 votes
2 answers
182 views

End Punctuation Checking using LuaLaTeX (like Reg-Ex)

I have need to check each paragraph ending end-period(.) is available or not. If missing need to put end-period LaTeX code \textcolor{red}{.} As per Automatically adding space before punctuation in ...
Kavi's user avatar
  • 143
0 votes
0 answers
35 views

Linenumbers include title, author using lualatex

I have got proper linenumbers in the twocolumn mode, except title and authornames . I have using LuaLaTeX Version 1.17.1. How to get auto linenumbers include all the texts(like title, author etc...). ...
Kavi's user avatar
  • 143
2 votes
0 answers
61 views

How to inject \directlua expansions back into TeX files

Is there a simple way (i.e. a flag to latexmk) to preprocess a source TeX file with LuaLaTeX, so that I get back the same source with just the invokations to \directlua expanded? My usecase is that I ...
Champitoad's user avatar
11 votes
1 answer
231 views

What is \directlua0{} vs \directlua{}

The title is the question. According to the LuaTeX manual, command \directlua{code} may have a 16-bit number between the command and the code, and I have seen \directlua0{code} here and there. But I ...
user avatar
4 votes
1 answer
67 views

In LuaLaTeX can I issue a LoadClass from a lua script invoked from a "user" class file?

LuaLaTeX: The desire is to maintain some parameters in a lua script and, from these, amongst other things, construct a \LoadClass statement which can be invoked from one's own class file. I can get ...
Chris Shattock's user avatar
3 votes
1 answer
184 views

Breaking equation with LuaLaTeX

The following code works as expected. It breaks mathematics expression in multi-lines. \documentclass{article} \usepackage{breqn} \begin{document} \begin{dmath*} f(1.02) + f (1.06) + f (1.1) + f (1....
user61681's user avatar
  • 1,789
3 votes
1 answer
117 views

Issue with new command in center environment using direct lua

\documentclass{article} \usepackage{luacode,xkeyval} \makeatletter \define@key{someop}{a}{\def\mop@one{#1}}% \setkeys{someop}{a=0}% \newcommand{\luaTest}[2][]{{% \setkeys{someop}{#1}% \directlua{% ...
user61681's user avatar
  • 1,789
0 votes
0 answers
50 views

LuaTex (?): Get access to the different layers of a glyph \char<No>

ExampleFontWithLayers01.zip (should be \char0) Sometimes a glyph is composed of different layers. Random example: But a command of type \char[layer=2]"1F0AE is not available at the moment. Is ...
cis's user avatar
  • 9,107
2 votes
1 answer
55 views

Throwing warnings inside \directlua

I'm trying to issue TeX warnings from within \directlua with accurate line numbers (pointing to the offending line in the .tex document). When I compile the MWE below with lualatex, \TestTex issues a ...
steve's user avatar
  • 2,301
0 votes
1 answer
303 views

[\directlua]:1: ')' expected near <eof>

In most cases I get this error: [\directlua]:1: ')' expected near . I want to calculate \Abs{((\bx-\ax)*(\cx-\ax)+(\by-\ay)*(\cy-\ay))/(809.55841)} and then round up \documentclass[margin=1cm]{...
Alain Matthes's user avatar
0 votes
1 answer
65 views

LuaLatex: create tabularx with multiple direclua

I'm using LuaLatex to create a tabular, but it work only if the entire tabular is created inside a single directlua. Why does the former work but not the latter ? This work \directlua{ tex.print(&...
tguichaoua's user avatar
2 votes
5 answers
260 views

obtaining a substring with \directlua when original string contains %-character

I want to implement in LaTeX a sort of function with two parameters a String containing a percentage e.g. "3.20 %" an integer, e.g. 2000 The result should be the product of both numbers (in ...
Thomas Monnerjahn's user avatar
1 vote
1 answer
216 views

TikZ---reading coordinates from an external file

I am trying to draw a picture with inputs from a bunch of csv files. Let's take the case where the content of the file is a simple tuple of floats: >>> cat coords/right_corner.csv 8....
Aubergine's user avatar
  • 252
4 votes
1 answer
125 views

Issue with percent signs in luacode (LuaLaTeX)

My example doesn't work at this location string.find(s:sub(1, 1), "%a"). How to fix it? MWE: % !TeX program = lualatex % !TeX encoding = utf-8 %===============================================...
Youra_P's user avatar
  • 1,172
4 votes
1 answer
181 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 ...
Paul's user avatar
  • 45
0 votes
1 answer
39 views

Pgfkeys .code and \directlua problem

Comment the 2 lines alternativelly, one works the other doesn't : \documentclass{beamer} \begin{document} \pgfkeys{/Baq/.cd , nb/.default = 10, nb/.store in = \nb, nb, contraintes/....
Tarass's user avatar
  • 17k
0 votes
1 answer
125 views

[\directlua]:1: invalid escape sequence - a no \string solution please

I have to pass different strings from latex to lua as arguments. I have a solution for an argument in a command, but in case of pgf keys, it seems not working. Use \string is not suitable, if it looks ...
Tarass's user avatar
  • 17k
2 votes
1 answer
62 views

Why is `tex.sprint` deferred when handling `process_input_buffer`?

%!TEX program=lualatex \documentclass{article} \begin{document} \def\specialRead{\directlua{ luatexbase.add_to_callback('process_input_buffer', function (line) if line:find('^\\...
Tuff Contender's user avatar
1 vote
1 answer
223 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{...
user61681's user avatar
  • 1,789
1 vote
1 answer
170 views

How can I get babel to use a fallback font when a special character is missing from the main font?

Sometimes there is a character in my text that is not in the main font, such as Chinese characters or emojis, etc. and I do not want to constantly modify this in the text with various commands to ...
seyal's user avatar
  • 67
1 vote
1 answer
127 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) ...
user61681's user avatar
  • 1,789
1 vote
2 answers
56 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$ &...
user61681's user avatar
  • 1,789
0 votes
1 answer
44 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} \...
atticus's user avatar
  • 607
2 votes
1 answer
357 views

How do you select individual end alternate/swash characters with LuaLaTeX and fontspec?

Basic Problem Statement I would like to enable some (but not all) stylistic alternate ".end" characters from an OpenType font, on condition that they replace terminal characters in a word. ...
jasonhathcock's user avatar
1 vote
1 answer
360 views

Table CHAR alignment in XML

I have successfully loaded XML in LuaLaTeX with XML-Tables based on this example Count Number of Columns in XML. I have need the table alignments from tbody instead of thead. And how to define ...
Balaji's user avatar
  • 2,282
1 vote
1 answer
73 views

Figure Text in same Document with Anchor Tag

I had referred this link: Create Separate File using LuaLaTeX But i have need in the same document. I would like to give anchor tags in the figure caption and move the figure caption text in the top ...
Balaji's user avatar
  • 2,282
1 vote
1 answer
163 views

Can I make a macro behave like \numexpr?

For example I define \fpeval in Plain LuaTeX: \begingroup \catcode`\%=12 \directlua{ function math.round_int ( x ) return x>=0 and math.floor(x+0.5) or math.ceil(x-0.5) end function ...
Weißer Kater's user avatar
2 votes
2 answers
225 views

\let\mySection\section with directlua

Next lualatex MWE emulates \newcommand\mySection{\section} on the lua side. % !TEX TS-program = lualatex \documentclass{article} \begin{document} \directlua{ token.set_macro('mySection', '\\section')...
Jérôme LAURENS's user avatar
0 votes
1 answer
52 views

Fixing error during collection of all boxes

i tired the code from this answer to arrange images loaded by includegraphics but got some errors i can not fix. the following code module(...,package.seeall) local function get_boxes(parent) local ...
susis strolch's user avatar
3 votes
1 answer
109 views

Command calls LuaLaTeX function, backslash in argument [duplicate]

I would like to create a command that simply prints what I give to it, but through Lua. Pointless for now, but I want to expand this to a more complex use-case. I've read a few answers around here, ...
likethevegetable's user avatar
1 vote
1 answer
961 views

Use unicode COMBINING LOW LINE (U+0332) as underline

In the same vein as Using unicode "combining right arrow above" to generate vector command, I’d like to use U+0332 “ ̲” as a “graphical” alias for \underline. I don’t know Lua, so I’m not ...
Archange's user avatar
  • 1,378
2 votes
1 answer
134 views

Can I make \directlua understand unicode chars like ≥, ≤, ≠, ∙, and −?

MWE: \directlua{% local abs=math.abs function gcd(x, y) if y \csstring\~= 0 then return gcd(y, x \csstring\% y)% I would like to write "≠" instead of "~=". else ...
Weißer Kater's user avatar
1 vote
1 answer
241 views

Problem writing to file through \directlua in a memoir class document

Below is a minimal example of some code where the memoir class seems to collide with Lua code, executed within a \directlua command, that writes to an external file. Can anyone help me figure out the ...
35royan2's user avatar
1 vote
1 answer
270 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\...
Sim Son's user avatar
  • 264
4 votes
1 answer
726 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 ...
codepoet's user avatar
  • 1,316
0 votes
0 answers
46 views

Unwanted spacing between text and tikzpicture caused by "non-visual" code lines

I want to show some subgraphs of a certain graph. I want them side by side and labeled. This is what I've got: I can't provide working LaTeX-code, since I have implemented the graphdrawing ...
Laffen's user avatar
  • 13
3 votes
2 answers
390 views

How to pass macro arguments (#1, #2, ..) to Lua variables

This question is probably trivial, but I started exploring Lua(La)TeX a couple of hours ago so bear with me. The MWE is the following: test.tex: \documentclass{article} \directlua{require("test....
noibe's user avatar
  • 2,094
0 votes
1 answer
75 views

Problem using macros in directua [duplicate]

I have the following external lua script: -- file mylua.lua function test(input) tex.sprint(input) end And the following lualatex document: \documentclass{article} \usepackage{luacode} \directlua{...
NVaughan's user avatar
  • 8,235
2 votes
0 answers
107 views

Incompatibility between LuaLatex font feature and Graphite?

when I use LuaLaTeX to modify my font (for example here kerning) at the same time as Graphite, there seems to be a problem because nothing happens. Everything seems to go well when I'm not using ...
Bastien's user avatar
  • 479
2 votes
1 answer
878 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")} ...
Oromion's user avatar
  • 424
2 votes
1 answer
520 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-...
Balaji's user avatar
  • 149
2 votes
1 answer
119 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 ...
user61681's user avatar
  • 1,789
5 votes
2 answers
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....
user61681's user avatar
  • 1,789
1 vote
1 answer
152 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 = {} -- ...
user61681's user avatar
  • 1,789
2 votes
1 answer
751 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 ...
user61681's user avatar
  • 1,789
4 votes
1 answer
166 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 ...
user61681's user avatar
  • 1,789
2 votes
1 answer
257 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 ...
user61681's user avatar
  • 1,789
3 votes
1 answer
158 views

siunitx table, formatting \directlua{} ouput

I have a table with values calculated with \directlua{}. They are formatted with siunitx columns. I want to turn some values bold or change their color. It appears that the output of \directlua{} ...
gwenj's user avatar
  • 121