Closed jemmybutton closed 2 years ago
I modified .sty and .lua files to work as described: luamplib_with_named_instances.zip
The following:
\mplibcodeinherit{enable}
\begin{mplibcode} % no instance name
beginfig(1);
a := 1/2cm;
draw fullcircle scaled a;
endfig;
\end{mplibcode}
\begin{mplibcode}[instance_one]
beginfig(1);
a := 1cm;
draw fullcircle scaled a;
endfig;
\end{mplibcode}
\begin{mplibcode}[instance_two]
beginfig(1);
a := 2cm;
draw fullcircle scaled a;
endfig;
\end{mplibcode}
\begin{mplibcode} % no instance name
beginfig(1);
draw unitsquare scaled a;
endfig;
\end{mplibcode}
\begin{mplibcode}[instance_one]
beginfig(1);
draw unitsquare scaled a;
endfig;
\end{mplibcode}
\begin{mplibcode}[instance_two]
beginfig(1);
draw unitsquare scaled a;
endfig;
\end{mplibcode}
produces this:
I didn't test it thoroughly though.
Thanks for the suggestion. Would you please make a PR?
@dohyunkim Sure! Done.
Thank you so much. A new version based on your contribution has just been sent to CTAN.
In some cases it may be useful to have several named MetaPost instances which can be referred to independently from LaTeX (similar to what ConTeXt offers). As far as I understand, currently, this can't be achieved using
luamplib
? The interface could look something like:(see also this) My naïve attempt at implementing a minimal workaround does seem to work ok:
But I'm sure it may break something elsewhere.