2 ms·
I was tickled to see my 2017 article pop up here. Lua is a somewhat odd but perfectly sane language that you can pick up in a day. With a few hooks into TeX yo
by leephillips 5y ago
I was tickled to see my 2017 article pop up here.
Lua is a somewhat odd but perfectly sane language that you can pick up in a day. With a few hooks into TeX you can be writing complex programs that manipulate your document, insert the result of calculations into the text, etc. Writing these things in TeX is insanely difficult. I’ve been using TeX literally since it became available, and I wouldn’t dare try to write anything complicated in TeX the programming language. But Lua is a breeze.
Because of this I’m a bit surprised that I haven’t seen more. One big application is the layout algorithm for network diagrams in tikz.
- coliveira 5y agoI agree that Lua is much easier to learn, however the kind of thing that you can do with such macros purely in Lua has limits. To do anything really important in LaTeX, you have to understand the LaTeX macro system, and you also need to have at last some understanding of the TeX language. You could do such things in Lua, but in that case you'll have to interface with LaTeX anyway. So in fact you're increasing the complexity of the task, because now you need to understand LaTeX and Lua. On the other hand, if you're just manipulating text that doesn't interface with LaTeX, then you could really do that from outside LaTeX, using any kind of script language such as python or perl. That's why I think that Lua scripting is not being used outside of some niche areas.
- leephillips 5y agoIn practice this is simply not the case. Look at my first example in the article. With just a few lines we can set a paragraph to follow the shape of any mathematical function. I didn’t have to know anything about TeX macros to do this. In fact I have no idea how to do this with LaTeX or TeX macros, and I don’t think they have nontrivial mathematical functions available. The same holds with the other examples. Almost trivial using Lua scripting (not “macros”), don’t even know where to start with TeX macros.