[metapost] "TEX(char 13)" in luamplib / plain MP
Toby Thurston
thurston at eml.cc
Thu Nov 21 12:34:24 CET 2024
Recently I was trying to solve a puzzling error message that someone asked about on TeX.SE, and I came across another minor difference between plain MP and luamplib.
If you run this trivial program through plain MP
> input TEX
> show TEX(char 13);
> end.
you get this in the log file
> >> Edge structure at line 2:
> setbounds path:
> (0,0)..controls (0,0) and (0,0)
> ..(0,0)..controls (0,0) and (0,0)
> ..(0,0)..controls (0,0) and (0,0)
> ..(0,0)..controls (0,0) and (0,0)
> ..cycle
> end of setbounds
> End edges
which shows that TEX() has returned a <picture> expression as expected (even though the picture is blank).
But if I run the equivalent programme through `lualatex`
> \documentclass{standalone}
> \usepackage{luamplib}
> \begin{document}
> \begin{mplibcode}
> show TEX(char 13);
> \end{mplibcode}
> \end{document}
I get an error like this:
> mplib warning: error in script: ...texlive/2024/texmf-dist/tex/luatex/luamplib/luamplib.lua:390: attempt to index a nil value (local 'box')
and in the log I get
> >> vacuous
> (luamplib) on input line 6
> ! Missing } inserted.
> <inserted text>
> }
> l.6 \end{mplibcode}
>
> ?
which suggests that TEX() has returned a <vacuous> expression instead of a <picture>.
The original context was that the person who asked the TeX.SE question was getting an error from an MP example of mine that
included the line
label(char 13 infont "eurm10", z0);
which is ok in plain mpost because "eurm10" does have a valid char at position 13 (a gamma), but the questioner was
trying to run the example through luamplib with `\mplibtextextlabel{enable}` so the `infont` trick meant that the line
was interpreted as
label(TEX(char 13), z0);
which generated the errors above.
I think it would be nice if the luamplib version of the TEX() macro always returned a <picture> even if it is empty.
T.
More information about the metapost
mailing list.