Feature request: Access to MP variable values from TeX/LaTeX?

Toby Thurston <[email protected]> Thu, 23 Oct 2025 18:07:01 +0100
Newsgroups gmane.comp.tex.metapost
Message-ID <[email protected]>
Currently `luamplib` sets the values `\MPwidth` and `\MPheight` after each figure is processed to provide information about the bounding box, but would it be possible to get access to the value of other variables that MP has calculated?   

For example, you might calculate the length of the side of a triangle and then want to refer to it in the text after the figure.  Sort of the opposite of the `\mpdim` mechanism which allows you to access TeX values from inside MP.

Something like this:

>   text before the figure.
> 
>   \begin{mplibcode}
>     beginfig(1);
>     % calculate values....
>     n = 42;
>     % etc...
>     endfig;
>   \end{mplibcode}
>   
>   From the preceding figure we can see that $n$ equals \MPvalue{n}...

The `tkz-elements` package provides `\tkzUseLua` that lets you get at a Lua value, so maybe there is a generic Lua way of doing this?

Toby



--
http://tug.org/metapost/