
LuaTeX Comes of Age - signa11
https://lwn.net/Articles/731581/
======
leephillips
I'm the author, and I'd be happy to answer any questions or take part in a
discussion about this.

~~~
PeachPlum
I know Lua

I process text (not in Lua). I do a bit of Troff, html, stuff like that.

Where to start learning ?

~~~
leephillips
First you need to learn a bit about how to use LaTeX. I learned this decades
ago and am not sure what is the best introduction now, but this is sometimes
recommended:

[http://ctan.mirrors.hoobly.com/info/lshort/english/lshort.pd...](http://ctan.mirrors.hoobly.com/info/lshort/english/lshort.pdf)

Then, look at the links in my article, and you should be able to start doing
something interesting.

~~~
0xdeadbeefbabe
I also wonder where to start, but with TeX and luaTex, and not LaTeX. Is that
a distinction worth making?

~~~
leephillips
Sure, if you want to use plain TeX, and not LaTeX. To get a really thorough
grounding, you can read Donald Knuth's TexBook. I'm sure there are also
briefer guides online.

~~~
0xdeadbeefbabe
I'm just wondering, and I don't really have an opinion.

~~~
mturmon
If you are an ordinary producer of documents (plain text, articles,tech
reports, letters, mathematical documents, etc.) you should start with LaTeX,
not TeX. It is uncommon to write in plain TeX and this has been so for many
years. In practice, you will use mostly LaTeX constructs, and the simplest TeX
ones, which the LaTeX guide would include.

------
skierscott
It appears the largest benefits is embedding Lua code into TeX (found at [1]
in "Programmability").

The example they present from that page:

    
    
        \documentclass{article}
        \usepackage{luacode}
        \begin{document}
        \pagestyle{empty}
        \begin{luacode*}
          function esn (n)
            return (1 + 1/n)^n
          end
          function etn (n)
            tex.print(string.format('%5d & %1.8f \\\\', n, esn(n)))
          end
        \end{luacode*}
    
        Convergence to $e$:
    
        \begin{tabular}{ll}
        \rule[-2mm]{0pt}{4mm}$n$ & $(1 + \frac{1}{n})^n$ \\
        \hline
        \luadirect{
          for n = 10, 110, 10 do
            tex.print(etn(n))
          end
        }
        \hline
        \end{tabular}
    
        \end{document}
    

which allows a pretty table to be printed in the document.

~~~
svat
That one simply inserts Lua code into TeX, and it's definitely a benefit
(alternative to complicated macros). IMO an even bigger benefit (not yet
widely used) are the various hooks and callbacks that LuaTeX provides -- you
can influence the operation of TeX by writing some callback code in Lua at the
right layer, instead of having to write everything in the input layer as
macros to be expanded so that things are set up for later when TeX rolls
around to do the thing you care about.

This also results in cleaner code (even beyond Lua being more readable than
TeX macros), and smaller/faster code as you don't have to account for as many
different kinds of things in your "input".

The "fade lines" callback example in the linked article is a good one. Here's
another example of mine (not a great one) where you can influence TeX's
linebreaking algorithm to avoid short words at line boundaries:
[https://tex.stackexchange.com/questions/378704/how-to-
avoid-...](https://tex.stackexchange.com/questions/378704/how-to-avoid-line-
breaks-that-result-in-short-words-at-line-edges/379802#379802) \-- the
solution with macros is not so great.

~~~
leephillips
That's brilliant - thanks for sharing that.

------
elfchief
Now, if only all of microtype's features were available in Lua(La)Tex. They're
the sole reason I'm still using pdfLaTeX, even though I end up not able to use
opentype fonts. :/

------
petters
Does microtype work equally well on Lualatex and Pdflatex these days? That
stopped me from switching years ago.

~~~
leephillips
My understanding is that some but not all microtype features are working, but
work is ongoing.

------
dsfyu404ed
Too bad this wasn't around when I was using LaTex to write a paper about Lua.

