Questions tagged [directlua]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
9
votes
1answer
132 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 % ...
6
votes
3answers
271 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
1answer
399 views

LuaLaTeX: Calculate length in Lua

I apologize if this a rookie question, but I find it extremely hard to find a solution to my Lua problem using online searches and browsing reference manuals. I would like to calculate a length: ...
5
votes
2answers
276 views

Code Comment in directlua

How can I add comments to my directlua code? {\catcode`\%=12 \directlua{ function boxed (s) ??? Add a comment ??? if not(boxedflag) then i=string.find(s,'^!!!') if(i==1) then boxedflag=true ...
5
votes
1answer
78 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{...
5
votes
1answer
234 views

Write to aux file directly from lua

Is it possible to write to the aux file directly from within a \directlua command? I am converting an older package to LuaLaTeX, which at some point builds a large string and writes it to the aux ...
5
votes
0answers
207 views

Pre-built preamble with LuaLaTeX and microtype

I have been trying to get super-fast compiles with LuaLaTeX by using a pre-built preamble for my documents. However, every time I try to compile, I get this error: No file main.aux. [\directlua]:1: ...
4
votes
3answers
242 views

Selecting a Specific Array Element in LuaTeX?

I need to create a command that goes \MyCommand{x,y} or \MyCommand{x,y,z} (both ways should be possible), where x, y, and z are three numbers. It should give the output \begin{matrix}x\\y\end{matrix} ...
4
votes
1answer
148 views

Fixing problems in latin translitteration of acute accented cyrillic vowels with \directlua

A good translitteration method from cyrillic to latin characters using XeLaTeX is discussed in Using XeTeX for automatic transliteration of cyrillic letters Actually I'm using LuaLaTeX. the ...
4
votes
1answer
72 views

Kerning of pairs with LuaTeX for babel shorthands

I want to make use of the pairwise kerning of this answer: https://tex.stackexchange.com/a/370469/75284 using fonts.handlers.otf.addfeature to adjust the kerning of character pairs with the hyphen -. ...
4
votes
1answer
140 views

How to get a customized number of decimal places in tex.sprint / directlua / qrCode?

The number of decimal places is "9" in the following example: string.format("\%0.9f", X). How can one achieve the replacement of the fixed "9" decimal places with "NumberOfDecimalPlaces" (in ...
3
votes
0answers
234 views

TeXstudio - Preventing syntax highlighting effects from LaTeX special characters in Lua code

Is there way to make TeXstudio ignore the contents of a \directlua command when performing syntax highlighting? Currently, it ends up causing highlighting like: Which is distracting when scanning the ...
2
votes
2answers
87 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 ...
2
votes
1answer
43 views

realscripts – can fakescripts substitute single missing chars

I have a font with real OT-superscripts which I can use easily with the realscripts-package. But I also need a superscript decimal dot which doesn't exist, thus realscripts falls back to the regular ...
2
votes
2answers
650 views

Using direct lua to read binary bytes to plain text?

In this thread, @David Carlisle tells us how to use luatex to read some of the properties of a png image. Alas, the image library seems to fail regarding the colorspace property. Always reports nil. ...
2
votes
1answer
45 views

Coerce LuaTeX into outputting a newline character

I encounter a problem when I wish to output a text file using a \directlua directive. There where I wish a newline character to be, I run into TeX problems. My solution is to invoke the dofile ...
2
votes
1answer
2k views

How to get a carriage return (newline) in directlua (tex.sprint) inside a QRCode?

How can one get a carriage return at the end of each line (Lualatex) ? \documentclass{article} \usepackage[nolinks,forget]{qrcode}% \begin{document} \newcommand{\Space}[0]{\ }% \newcommand{\...
1
vote
1answer
66 views

How can I use math.log10 function with the directlua?

I would like to know how I can use math.log10 function with the directlua, because I always get none from directlua. Following a minimal example: %Engine: LuaLaTeX; %Encoding: UTF-8; \documentclass[...
1
vote
0answers
205 views

Create external file (like a Makefile) whit real tabs using LaTeX and Lua code

I'm trying to generate a external Makefile (and others) file using latex and the filecontents or fancyvrb package. As the \t (tabs) characters in input file are converted to space in output file (see ...
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 ...