[lltx] luamplib + lualatex
Dohyun Kim
nomosnomos at gmail.com
Tue Jan 28 02:58:53 CET 2014
It's been long time since last mail on this thread. Now at last I seem
have a solution on this issue. As luamplib has been upgraded recently,
the issue Troy raised can be solved as follows:
\documentclass{article}
\usepackage{luamplib}
\everymplib{
if (readfrom "mymplibtmp.mp" <> EOF):
input mymplibtmp;
fi;
closefrom "mymplibtmp.mp";
if unknown u: u := 1; fi;
beginfig(0);
}
\everyendmplib{
endfig;
write "u := " & decimal u &";" to "mymplibtmp.mp";
write EOF to "mymplibtmp.mp";
}
\begin{document}
\raggedright\leavevmode
\newcount\n \n=0
\loop \ifnum\n<20 \advance\n by 1
\begin{mplibcode}
draw fullcircle scaled u;
u := 1.1u;
if u > 100: u := 1 fi;
\end{mplibcode}
\repeat
\end{document}
Regards,
Dohyun Kim
2013-07-25 Dohyun Kim <nomosnomos at gmail.com>:
> 2013/7/25 Troy Henderson <thenders at gmail.com>:
>> This works very well. The only issue I see is if I update the value
>> of a variable, then that updated value is not remembered by another
>> \begin{mplibcode} ... \end{mplibcode}. For example,
>>
>> \begin{mplibpreamble}
>> u:=54;
>> \end{mplibpreamble}
>> \begin{mplibcode}
>> beginfig(1);
>> draw fullcircle scaled (2*u);
>> u:=2*u;
>> endfig;
>> beginfig(2);
>> draw fullcircle scaled (2*u);
>> endfig;
>> \end{mplibcode}
>>
>> draws two circles where the second circle has twice the diameter as
>> the first. However,
>>
>> \begin{mplibpreamble}
>> u:=54;
>> \end{mplibpreamble}
>> \begin{mplibcode}
>> beginfig(1);
>> draw fullcircle scaled (2*u);
>> u:=2*u;
>> endfig;
>> \end{mplibcode}
>> \begin{mplibcode}
>> beginfig(2);
>> draw fullcircle scaled (2*u);
>> endfig;
>> \end{mplibcode}
>>
>> draws two circles of the same diameter (namely 54bp). Perhaps there
>> could be an optional argument to \begin{mplibcode} that would NOT use
>> the preamble, or perhaps there's a better solution than the optional
>> argument.
>>
>
> Currently, I have no idea about how to inherit the variables of
> previous environment.
More information about the lualatex-dev
mailing list