
다음 코드는 정상적으로 작동합니다.
\documentclass{article}
\usepackage{luamplib}
\begin{document}
\begin{mplibcode}
input graph ;
beginfig(0) ;
draw begingraph(5cm,3cm)
gdraw (0,0) for x = 1 upto 3: .. (x, x) endfor ;
endgraph ;
endfig ;
\end{mplibcode}
\end{document}
그러나 다음은 작동하지 않습니다.
\documentclass{article}
\usepackage{luacode}
\usepackage{luamplib}
\begin{document}
\def\plot{
\directlua{
tex.print("\string\\begin{mplibcode}")
tex.print("input graph ;")
tex.print("beginfig(0)")
tex.print("draw begingraph(5cm,3cm)")
tex.print(" gdraw (0,0) for x = 1 upto 3: .. (x, x) endfor ;")
tex.print("endgraph;")
tex.sprint("endfig;")
tex.print("\string\\end{mplibcode}")
}
}
\plot
\end{document}
mplibdoreplacenewlinebr
또는 에 문제가 있는 것 같습니다 catcode
. 이 오류는 어떻게 처리할 수 있나요?
답변1
Lua에서 사용하고 있으므로 luamplib
Lua 인터페이스를 사용하고 \being...\end{mplibcode}
.
\documentclass{article}
\usepackage{luamplib}
\begin{document}
\def\plot{%
\directlua{luamplib.process_mplibcode([[
input graph ;
beginfig(0)
draw begingraph(5cm,3cm)
gdraw (0,0) for x = 1 upto 3: .. (x, x) endfor ;
endgraph ;
endfig ;
]])}%
}
\plot
\end{document}