3 ms·
LuaTeX is another way to create LaTeX macros, but using Lua as the language to manipulate text. I think it helps create macros that would be too complicated in
by coliveira 5y ago
LuaTeX is another way to create LaTeX macros, but using Lua as the language to manipulate text. I think it helps create macros that would be too complicated in TeX, but on the other hand it is another language for LaTeX users to learn. I haven't see much advantage of their approach other than in specialized niches such as creating complex figures.
- mr_mitm 5y agoLaTeX isn't just for users, there are also people who are developing packages or classes. And since LaTeX doesn't even offer the luxury of arrays or hash tables natively, LuaTeX is very a refreshing change. My company is using their own LuaLaTeX class extensively to produce hundreds, if not thousands of reports per year, and features like automatically computing the CVSS base score of a CVSS vector will take a couple of minutes in lua, while it will cost you several days and a bunch of gray hairs to do in TeX. It's only the developer who has to know any lua though. It's completely transparent to the user.
- PaulHoule 5y agoI took a class in TeX a long time ago and got marked off a point because I used self-modifying macros to save a variable.
- leephillips 5y agoSounds like it should have been extra credit.
- nanna 5y agoAppreciate you giving an example of a real world use for the Lua in LuaLaTex. Any others appreciated! Like the parent, i've never much come up with a possible application.
- leephillips 5y agoI 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.