Questions tagged [luacode]

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

Filter by
Sorted by
Tagged with
1 vote
0 answers
37 views

How to insert LaTeX commands through LuaLaTeX callbacks?

I would like to encourage LaTeX to break a line or page at the end of a sentence, after one of the following punctuation marks: "." ; "!" and "?". I would like to put a ...
user avatar
  • 325
1 vote
1 answer
27 views

Reduce the space between letter "f" and subscript that follows for Asana-Math (unicode-math)

Following the second part of this answer, I'm trying to do the similar thing for Asana-Math: reducing the space between letter "f" and the subscript that follows. However, my modified ...
user avatar
  • 6,542
0 votes
3 answers
69 views

Lua function returning a list of values to TikZ foreach loop

I was trying to come up with a Lua-based solution to another question here and failed miserably. There something I certainly don't understand about LuaLaTeX. Here is a toy code that shows the problem. ...
user avatar
  • 1,712
1 vote
1 answer
38 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) ...
user avatar
  • 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$ &...
user avatar
  • 1,443
1 vote
1 answer
85 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", ...
user avatar
  • 387
3 votes
2 answers
126 views

LuaTeX strings and xspace

I am using lua code to automate recording todos that come up during meetings I take minutes of. For this I use \luastringN from the luacode package currently. However, I would like to have all the '...
user avatar
0 votes
0 answers
45 views

Make a copy of the pdf file using lua

I would like to make a copy of the pdf file, but the following command (just before \end{document}) doesn't work. \directlua{os.execute("cp \jobname.pdf \jobname_bis.pdf")} My aim is the ...
user avatar
  • 749
1 vote
1 answer
78 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 ...
user avatar
  • 2,172
1 vote
1 answer
103 views

Split Table to Next Page - LuaLaTeX

I have need to split the table to next page without using longtable package. Because longtable package is not supporting directly float. MY MWE is: \documentclass{article} \usepackage{luacode} \begin{...
user avatar
  • 2,172
1 vote
1 answer
31 views

Delete a file using luacode

I would like to delete a file called \jobname.someext which is in the same directory of my .tex file, at the beginning of a typesetting. I know the shellesc package, but can I do this with a luacode ?
user avatar
  • 749
1 vote
1 answer
53 views

XML Keyboard Characters to TeX Characters - LuaLaTeX

I would like to convert all the XML Keyboard Characters to LaTeX Code Conversion. For Example $ should convert to \$, { should convert to \{ in LaTeX. How to achieve this? I know it's possible to do ...
user avatar
  • 2,172
1 vote
1 answer
48 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 ...
user avatar
  • 2,172
3 votes
1 answer
101 views

Create Separate File using LuaLaTeX

My Input LaTeX FileName is Article05.tex. I would like to find the text <stepn number>(.-)</stepn number> and store the text is individual file like name is Article05-step.tex. How to ...
user avatar
  • 2,172
0 votes
1 answer
225 views

How to change output PDF filename(LuaLatex)

I'm using Lualatex and looking for a way to change the name of the output PDF generated. Can I do this via command line arguments when calling Lualatex to compile my document? or can it be set ...
user avatar
  • 37
0 votes
1 answer
114 views

Looping and printing code with luacode

I intend to print several plots by using pgfplots and a CSV file with several columns, one for each plot. this is how it would be implemented for a single column: \documentclass[12pt]{article} % lua \...
user avatar
  • 79
1 vote
1 answer
87 views

How to pass an argument to lua tex.print with maths

I want to create a blank exercise, in which answers can be text or mathematical expression, and to have below a list of all answers in disorder. In the MWE i made with LUA, the text appears below as ...
user avatar
3 votes
1 answer
49 views

luaxml always outputs with one letter indentation

I have a code to process an xml file and fill tcolorboxes with its contents. I'm using luaxml but it seems that i always get one letter indentation. Latest luaxml is needed. The code is here and a ...
user avatar
4 votes
1 answer
68 views

Automatically formating all-caps passages with lualatex

I want to apply specific formatting to all all-caps passages in a longer text, specifically tracking/letterspacing using fontspec's mechanism, so it can be adjusted for different font-styles. I have a ...
user avatar
  • 2,817
0 votes
1 answer
62 views

Last Word not break avoid automatically

I have need to avoid last word break. It must print in PDF before the line or break with previous word. My MWE IS: \documentclass{book} \doublehyphendemerits=100000 \frenchspacing \usepackage{...
user avatar
  • 2,172
0 votes
0 answers
75 views

Luacode with several .tex files [duplicate]

I wrote some luacode in my main.tex and I'm a adding several other files due to \input{code.tex} I already asked this question here and it works on a standalone environment but not in my case. I can't ...
user avatar
1 vote
3 answers
149 views

Generate table using formula

What is the simplest most universal way to generate a table using a formula? Minimal amount of code that is most robust. I simply want to essentially generate a table of values where the values are ...
user avatar
  • 143
0 votes
1 answer
102 views

Lua Multiple for-loop statement

My XML Look is: <contrib-group content-type="all"> <contrib contrib-type="author"><name><surname>Bronnikov</surname><given-names>Kirill A<...
user avatar
  • 2,172
13 votes
3 answers
1k views

Avoid Three Consecutive Hyphens

I need to suppress occurrences of 3 consecutive lines of text that end in hyphenated words. How to solve this? My LaTeX Source Code is: \documentclass{book} \usepackage{luacode} \begin{document} \...
user avatar
  • 2,172
2 votes
1 answer
205 views

Count Number of Columns in XML

I have successfully loaded XML in LuaLaTeX but how to load XML-Tables? \documentclass{book} \usepackage{luacode} \begin{document} \begin{luacode*} local domobject = require "luaxml-domobject&...
user avatar
  • 2,172
0 votes
0 answers
44 views

Calculated solution is not recognized as value

In the code below it should be checked if treq<t. In TEST 1, treq is specified as 2.93. The condition treq<t is met and turns blue (or red). \ifthenelse condition works fine. In TEST 2, xreq is ...
user avatar
  • 21
0 votes
0 answers
94 views

Substitute font usage in XeLaTeX/LuaLaTeX

I have using LuaLaTeX and is there any way to tell XeLaTeX/LuaLaTeX to make automatic substitutions if the font is missing glyphs? My LaTeX MWE: \documentclass{article} \usepackage[no-math]{fontspec} \...
user avatar
  • 2,172
0 votes
1 answer
188 views

tex.sprint in LuaLaTeX

I would like to print text as per XML file. But when using tex.sprint enter mark is removed and all the text are displayed in single line in PDF. How do avoid this? My ds.tex file is \documentclass{...
user avatar
  • 2,172
2 votes
1 answer
164 views

Pass preceding character to a command LuaLaTeX

I want to make a character active/sensitive and pass its preceding character as an argument of some command. I could do it using LuaLaTeX engine and luacode package. Thanks to this and this post. % !...
user avatar
  • 2,303
0 votes
1 answer
435 views

Error message from including luacode package in Overleaf

I am including the LuaTeX into an Overleaf LaTeX document by \usepackage{arxiv} \usepackage[T1]{fontenc} % use 8-bit T1 fonts \usepackage{hyperref} % hyperlinks \hypersetup{ colorlinks=...
user avatar
  • 115
2 votes
1 answer
340 views

Find and replace string with leading comma and space using lualatex and gsub, or a macro

I need to get rid of mulitple instances of hyperlinked text ", foo bar" in my compiled latex document. It would be incredibly laborious to employ global find and replace on source code ...
user avatar
  • 127
2 votes
1 answer
315 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-...
user avatar
  • 85
0 votes
1 answer
77 views

Is this a good way to change \section in document using luacode? Or could this be done using plain Latex macro?

I wanted to do simple thing. Change each \section to \cprotect\section in the whole document. I could not figure out how to do it using latex macro. So I used lua I'd like to ask if you think this ...
user avatar
  • 18.4k
2 votes
1 answer
79 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 ...
user avatar
  • 1,443
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....
user avatar
  • 1,443
1 vote
1 answer
109 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 = {} -- ...
user avatar
  • 1,443
2 votes
1 answer
379 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 ...
user avatar
  • 1,443
4 votes
1 answer
129 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 ...
user avatar
  • 1,443
2 votes
1 answer
152 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 ...
user avatar
  • 1,443
3 votes
1 answer
205 views

Gregorio - Glyph missing?

I've just updated to TexLive 2019 on Mac and then Gregorio 5.2.1. This is the file I'm trying to compile (with my past distribution of TexLive 2018): % !TEX program = LuaLaTeX+se % !TEX encoding = ...
user avatar
  • 33
4 votes
1 answer
264 views

Using Lua in tikzpicture

I am currently exploring ways to generate TikZ code using LuaTeX. Using the luacode* environment seems to be smooth sailing. But sometimes it seems to make more sense to just inject small fragments ...
user avatar
  • 921
2 votes
1 answer
187 views

PythonTeX: Using LaTeX macros in pyblock

Is possible to use LaTeX macros in pythonTeX pyblock environment and use/store theyre output on python side of pythonTeX? Following MWE should completely illustrate my question: \documentclass[11pt]{...
user avatar
0 votes
1 answer
168 views

error: Font \TU/LatinModernRoman(0)/bx/n/10=LatinModernRoman

Everything was working fine in my main document before trying to embed this answer in my code. However, I don't quite understand the steps needed to resolve this according to this solution. The error ...
user avatar
  • 8,769
0 votes
1 answer
27 views

Processing luatex callback functions when creating glossary with bib2gls

In my project, I am looking for simple, but automated string replacement. For that I have hit upon this question and its answer: What packages provide text/command substitution for LaTeX, XeTeX and ...
user avatar
15 votes
2 answers
963 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 ...
user avatar
  • 1,443
0 votes
0 answers
176 views

Issue with xparse and lualatex

I have the following code \documentclass{article} \usepackage{luacode,xparse,amsmath} \begin{luacode*} local matrix = require "matrix" local complex = require "complex" function add(m,n) m=...
user avatar
  • 1,443
1 vote
1 answer
184 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} \...
user avatar
  • 1,443
0 votes
1 answer
168 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{...
user avatar
  • 1,443
4 votes
2 answers
161 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 ...
user avatar
  • 1,443
2 votes
2 answers
436 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 ...
user avatar
  • 1,443