4 ms·
> (I've even considered moving over to LuaTeX because it would allow more automation, but I'd need a pretty longish period of reimplementation that I don't see
by dkna 6y ago
> (I've even considered moving over to LuaTeX because it would allow more automation, but I'd need a pretty longish period of reimplementation that I don't see becoming available soon.)
Good thing you didn't bother, because it's absolutely not worth it. I chose LuaTeX initially precisely because it seemed more convenient to write commands in Lua than in plain LaTeX, but it turned into a total nightmare. Issues crop up as soon as you try to do something with text that embeds LaTeX macros, and the errors you get are even more byzantine than the ones you'd get by writing "normal" LaTeX code.
IMHO the very idea of embedding an external language into LaTeX is pointless, for the simple reason that LaTeX isn't markup, but code, and that it's pretty much impossible to parse it into a representation that makes sense and could be manipulated like, say, the HTML DOM. The only sane way to automate things is to write your documents in some language or markup that can be compiled to LaTeX, or to use a template engine.
- svat 6y ago> Good thing you didn't bother, because it's absolutely not worth it. The biggest thing LuaTeX gives you is variou hooks and access to various data structures used internally by the typesetting engine, so that you can work with them directly instead of having to do everything in a roundabout way through macro expansion. If all you need is text expansion then sure, just use TeX/LaTeX macros. (You mentioned "try to do something with text that embeds LaTeX macros"; I think working at the text level like that is a sign that your problem, or at least your solution, may not be a good fit for what LuaTeX gives.) Here are a couple of my answers where LuaTeX was valuable; you can find hundreds more (IMO) by others: - https://tex.stackexchange.com/a/379802 https://tex.stackexchange.com/a/379802 Avoid getting short words at line edges: Note that the macro-level solution runs into issues with \ref etc (just as you said about text that embed LaTeX macros), but the LuaTeX solution works perfectly in all cases - https://tex.stackexchange.com/a/401315 https://tex.stackexchange.com/a/401315 Letter-spacing - https://tex.stackexchange.com/a/403353 https://tex.stackexchange.com/a/403353 Typesetting on a poster with some image cut out - https://tex.stackexchange.com/a/416772 https://tex.stackexchange.com/a/416772 Doing text replacements based on TeX macro state (maybe this could be done without LuaTeX?) - https://tex.stackexchange.com/a/414013 https://tex.stackexchange.com/a/414013 Inserting random kerning I do completely agree with your recommendation of generating TeX/LaTeX if possible (and keeping the macros/LaTeX to a minimum).