
luamplib
환경 내에서 Lua 기능을 실행할 수 있나요 ? runscript를 사용한 이 예제는 작동하지 않지만 내가 원하는 작업을 보여줍니다.
\documentclass{article}
\usepackage{iftex,luamplib}
\begin{filecontents}[force,noheader]{foo.lua}
function getA()
return "2cm"
end
\end{filecontents}
\begin{document}
\directlua{kpse.set_program_name("luatex") require "foo.lua" }
\begin{mplibcode}
beginfig(1);
a := runscript("getA()") ;
draw fullcircle scaled a ;
endfig ;
\end{mplibcode}
\end{document}
최신 TL 2023
답변1
이는 가능합니다. 다음과 같이 return
에 전달하는 문자열에 명령문 만 있으면 됩니다.runscript
\begin{mplibcode}
beginfig(1);
a := runscript("return getA()") ;
draw fullcircle scaled a ;
endfig ;
\end{mplibcode}
의도한 대로 2cm 크기의 원이 그려집니다.