我们希望mpgraphics可以自动重命名,并将图的标题改为该重命名。可以这样实现:
\makeatletter
\NewDocumentEnvironment{mpfig}{m}{%
\stepcounter{mpgfig}%
\xdef\MPGCutFile{\mpgfigname.mp}
\MPGverbatimwrite{\MPGCutFile}
}{
\endMPGverbatimwrite%
\MPGgraphicsinclude%
\IfFileExists{\mpgfigname.\[email protected]}{%
\immediate\write18{cp "\mpgfigname.\[email protected]" "img/#1.\[email protected]"}%
{\begin{center} \thempgfig:#1 \end{center}}%
}{
\csname @[email protected]@\[email protected] true\endcsname
}
\global\@[email protected]\noindent%
}
\makeatother
添加上述代码到preamble区域。然后可以这样使用
\begin{mpfig}{a-circle}
draw fullcircle scaled 100pt;
\end{mpfig}
则可以重命名生成的文件到`img/`目录下(需要自己创建), 请用pdflatex编译。
本作品采用创作共用版权协议, 要求署名、非商业用途和保持一致. 转载本站内容必须也遵循署名-非商业用途-保持一致的创作共用协议.