Questions tagged [lua]

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

Filter by
Sorted by
Tagged with
33
votes
6answers
9k views

Reading data from a relational database into a LaTeX table

I'm using Tex Live 2009 on Debian squeeze. I can upgrade if I really, really have to, but I'd rather not. I was wondering if it would be possible to do the following. Given some data in a (...
93
votes
5answers
22k views

What is a simple example of something you can do with LuaTeX?

I've heard that with LuaTeX, you can embed Lua code in your document that work directly with TeX internals, making it possible to do several things that are hard to do with macros. What is a good ...
10
votes
3answers
1k views

How to do a 'printline' in LuaTeX

I have just started exploring the world of LuaTeX and wanted to write a piece of code, that prints a name to a new line in the document. \directlua{ for i=1,3,1 do tex.print("FOO") end } which ...
21
votes
2answers
2k views

LuaJIT and LuaTeX

Is it possible to change the Lua engine in LuaTeX to LuaJIT? Will it be as simple as replacing the Lua5.1 source code in the LuaTeX tarball with the LuaJIT source, or does it require (drastic) ...
10
votes
1answer
223 views

Call a (luatex-)combo font through NFSS

After some struggles I found a way to call a combo-font (which combines glyphs from two fonts) so that I can get various font sizes. Has anyone an idea how one could inject this code (or other code ...
2
votes
1answer
186 views

references to floats without ever using figure numbers (possbily using lua or python)

Stephen Wolfram's 'A New Kind of Science' states in its colophon that it has 973 illustrations spread out over 1280 pages. Remarkably, he accomplishes this without ever using figure numbers. No figure ...
51
votes
5answers
6k views

Practical use of Lua

Although I always use LuaLaTeX to compile my documents, I don't really use Lua that often. Sometimes I even forget about it. In my last document I used it to write a random word generator, which ...
29
votes
3answers
22k views

How to properly install and use a new font with LuaLaTeX?

I have problems trying to get new fonts to work when compiling with LuaLaTeX. I'm working on Mac and use TexShop (with the MacTeX package). It goes like this: I downloaded for example the Cardo font;...
16
votes
1answer
2k views

Installing Lua Modules for use in LuaLaTeX

I've done all of the searching that I can, and I think I've read the right answer, but am too dumb to know that I read it. I can't seem to figure out the magic tricks to get Lua modules, installed by ...
26
votes
1answer
527 views

Bad interaction between fontspec and some lua code that performs string-related search and replace operations

Update 2013/05/28: The selnolig package is now on the CTAN. Comments and critiques always welcome! If you wish to contact me about any aspects of the package, please use the email address that's given ...
3
votes
1answer
487 views

Write/Read values of the LaTeX commands (like \title, \ author etc) in file using Lua

This problem relate with other my question here . I found a solution with pdfpages package thanks to TX.SX: \documentclass[]{scrbook} \usepackage{authblk} \usepackage{pdfpages} \newcommand{\...
42
votes
7answers
5k views

What are the advantages of Lua over other scripting languages for a TeX implementation?

The question is inspired by Martin Schröder's answer to I am new to TeX. Should I use LaTeX, XeLaTeX, …? as well as my two previous questions on this forum: Automatic document update Generate LaTeX ...
39
votes
1answer
756 views

Replacement(s) for TeX's paragraph builder using LuaTeX

The LuaTeX engine provides a callback that allows you to replace the built-in paragraph builder by your own algorithm. My question is twofold: does there exist a lua implementation that fully (or ...
11
votes
3answers
3k views

Matrix multiplication (and other operations) macro using lua module

I am hoping to be able to create a macro to multiply matrices using a lua module. The module is here: https://raw.github.com/davidm/lua-matrix/master/lua/matrix.lua As suggested to me in a previous ...
20
votes
4answers
2k views

How to read a file with luatex

I tried to read a file with lua and set the content as normal text in my document, but I didn't worked it out. Here my code: \documentclass{scrartcl} \usepackage{luatextra} \usepackage{filecontents} ...
14
votes
2answers
429 views

Fill a lua table with lowercase/uppercase pairs.

I would like to add the Letters=Uppercase option to a font which hasn't the needed open type feature built in. This is (with lualatex) possible like this: \documentclass{article} \directlua { ...
9
votes
1answer
650 views

Convert all all-caps words to small caps

I'd like to turn all all-uppercase words, acronyms etc. into small caps, preferably automatically on the fly and without changing the source files. The ideal solution would also allow me to block some ...
7
votes
3answers
690 views

Problem printing LaTeX from lua in lualatex

I am having difficulty printing LaTeX from a lua function in a LaTeX document processed with lualatex (version 0.70.2). I have a sample that works (if I remove all newlines from the code) and a case ...
7
votes
2answers
1k views

Using macro variables with Lua in ConTeXt

I need to make some macros in ConTeXt. I have tried to use Lua code, but I do not understand how to mix ConTeXt source and Lua source together. Here is an example: \define[3]\textmacro{ \startlua ...
7
votes
4answers
362 views

How can I retrieve \thepage (or detect a page change) from Lua in LuaTeX?

I am writing (contributing to) a LuaLaTeX package where a Lua function is used to generate images that are inserted in the LaTeX document. One piece of information we need is the current page number ...
3
votes
1answer
569 views

hyperref error : ! Argument of \@providesfile has an extra }

Using a solution to adjust spacing in my document with LuaLaTeX, I run into this cryptic error, as soon as I use \label{} in a math environment: (c:/texlive/2016/texmf-dist/tex/generic/oberdiek/se-...
1
vote
2answers
753 views

Print large macro block from Lua to TeX

I have a rather large block of TeX macro code that is no problem to do in TeX but I'd like to create the macro in Lua instead The macro contains various TeX macro characters (\, %, [, ]) How can I ...
9
votes
2answers
1k views

How to manipulate a multi-line string in luatex?

I want to write a Lua function that processes some multi-line string. Thus, I created a new file test.lua which contains userdata = userdata or {} function userdata.surroundwithdashes(str) str = ...
9
votes
2answers
848 views

percent signs in luacode* environment (LuaLaTeX)

Can someone explain what happens here: \documentclass{article} \usepackage{luacode} \begin{document} \begin{luacode*} tex.print("xx\%a","yy\\%b","zz\\\%c") \end{luacode*} \end{document} The result ...
9
votes
3answers
3k views

What is the correct way to delineate directories in Lua?

I have been experimenting with some Lua code to list directories and provide them to the TeX engine. I have been using the Lua File System (lfs) module. The first part list the current directory (...
5
votes
1answer
160 views

Strange ConTeXt fail to load pgf.gd.control

I'm playing with PGF's (algorithmic) graph drawing, which relies on Lua internally. I have no problems with LaTeX, but ConTeXt fails to load the package. For the simple document: \usemodule[tikz] \...
3
votes
1answer
84 views

Custom spacing and TikZ

Using a solution to adjust spacing in my document with LuaLaTeX, I run into the problem, that the semicolons are also replaced in a TikZ environments: MWE: \documentclass{scrbook} \usepackage{tikz} ...
1
vote
1answer
88 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} \...
30
votes
1answer
2k views

Best Practices for Lua Modules

In the Lua world Lua Modules are installed using LuaRocks. With LuaTeX these modules are normally installed in the scripts folder (under MikTeX windows). What tools are available for downloading and ...
21
votes
1answer
2k views

LuaLaTeX for dummies: basic directlua use

I'm trying to understand the basics of lua programming within LaTeX. I have this simple function in a file called luatest.lua: function fact (n) if n == 0 then return 1 else return n * ...
8
votes
1answer
7k views

Search & Replace Script for TeXworks

Does anyone have an example for a search & replace lua script that I can use with TeXworks. I have a rather large document here (about 3'000 pages DIN A5) which I need to update continously. To ...
9
votes
2answers
3k views

My first luaLaTeX example

I am totaly inexperienced in LuaLaTeX and I don't know why but it was somehow very difficult to find working LuaLaTeX example so I can start playing around. I finaly found the example in a document ...
12
votes
0answers
285 views

metafun: Why is the arrow tip not filled? [closed]

Trying out another example I saw that with the metafun format (luatex version) the arrow tips are no longer filled. The following document (to be compile with lualatex) shows the problem: \...
9
votes
0answers
1k views

How to add/check missing punctuation marks (itemize/enumerate) automatically?

(An experiment) I'd like to present you one of the possible tasks (to be automated) I solve in my daily work: adding missing punctuation marks in the itemize and enumerate environments. I polish ...
6
votes
1answer
848 views

LuaTeX: How to handle a Lua function that prints TeX macros

Let's say that I have a Lua function that prints TeX macros: How can those macros be executed during compilation with LuaLaTeX? In the following example, I defined a LaTeX macro that should print a ...
4
votes
2answers
469 views

Automatically adding space before punctuation in LuaLaTeX

I'm typesetting a text in which I want to add space before double punctuation using LuaLaTeX. To give you the idea: Using this answer and this one, I wrote following code which do not work (for "Test!...
22
votes
1answer
270 views

How to use luatex's node.hpack so that marks, inserts and vadjusts migrate out?

TeX's hpack routine packages an hlist into a box. While doing that it looks at a global pointer adjust_tail and if that is not "null" it migrates some nodes to a separate list starting at adjust_head....
7
votes
1answer
1k views

How to get vector graphics from Concorde program?

Back in around 2009/2010, my former colleague Libor Sarga (a beginner in TeX at that time), asked me if I could help him to get a vector form of his results obtained from Concorde. He was writing a ...
7
votes
2answers
982 views

How to display special symbols in ConTeXt which are processed by Lua?

I have a ConTeXt document containing many special characters. I have followed the instructions at Which symbols need to be escaped in ConTeXt? to ensure they can all display properly in the document, ...
5
votes
3answers
625 views

Auto replacement of characters

To make it very simple, I want to change the mapping of keyboard keys and unicode characters, but not by programming. I want to do it with LaTeX. eg. As suggested by @Ulrike and @Phelype I've edited ...
5
votes
1answer
123 views

LuaLatTeX inefficiency in transliteration from cyrillic of acute accented vowels

Transliteration from cyrillic to latin characters can be done in LuaLaTeX with the help of directlua as shown by @DavidCarlisle: Create a mapping for transliteration from cyrillic to latin in LuaLaTeX ...
4
votes
2answers
112 views

Insert LaTeX code at line break

Is there a way to insert arbitrary (La)TeX-code at the line break of a typeset line? I am aware that this isn't really possible with (La)TeX as such. But looking at all the interesting chickenize-...
3
votes
1answer
653 views

LuaLaTeX output from tex.print not interpreted

This is a follow-up from my previous answer to Automated Creation of Questions and Solutions for a Worksheet/Exam. I realised, that the macros I created like this \ewcommand{\currentI}{\directlua{tex....
3
votes
0answers
147 views

Bake LuaSQL into luatex binary on Windows

Further to this question, I want to build luatex on Windows with the LuaSQL library baked in, at least with the ODBC drivers. This post by Taco Hoekwater back in 2010 walks through the process for ...
2
votes
0answers
732 views

Debugging Lua in LuaLatex with LDT [closed]

LDT is an IDE for lua based on eclipse. It is quite nice and the best free lua debugger I've seen(I've just stumbled upon it the last 2 days or so). It took me a bit to get setup properly but because ...
2
votes
1answer
2k views

Install make4ht with MiKTeX

I am trying to install make4ht on a system running MiKTex. The recommended instructions https://d800fotos.wordpress.com/2015/01/19/create-e-books-from-latex-tex-files-ebook-aus-latex-tex-dateien-...
11
votes
1answer
484 views

Convert color name to pdfliteral code

How can I convert a color name (such as used with the xcolor package) to a pdfliteral code, like q 1 0 0 rg (for red)?
9
votes
3answers
4k views

How to check if a value is not equal using TeX conditionals?

I have a value defined in a macro, e.g.: \mymacro{apple} I need to check if a value does not equal a string, e.g.: IF #1 NOT EQUAL TO "apple" THEN PRINT "It is not a apple, it is #1." FI I ...
8
votes
1answer
926 views

Pass parameter to texlua script

Calling texlua file.lua on the command line runs the file through a Lua interpreter. Is it possible to give arguments to the script? For instance, in -- file.lua io.write(3.4 + 5.6) io.write("\n") ...
5
votes
1answer
114 views

Automatically highlighting nominalizations (a.k.a. zombie nouns) as a writing aid

To improve my writing, I want to reduce the number of nominalizations (a.k.a. zombie nouns) that I use. For that purpose I would like to have all nominalizations automatically highlighted in the ...