Trevor
I am currently making some diagrams in MetaPost. To make them, I am using LuaTeX's `luamplib` package, which was recommended in Toby Thurston's [Drawing with Metapost](https://github.com/thruston/Drawing-with-Metapost/blob/main/Drawing-with-Metapost.pdf). Here is an example:
```
\documentclass{standalone}
\usepackage{luamplib}
\begin{document}
\begin{mplibcode}
beginfig(1);
draw fullcircle scaled 25;
endfig;
beginfig(2);
draw fullcircle scaled 25 withcolor red;
endfig;
\end{mplibcode}
\end{document}
```
![metapost_drawing.png](/image?hash=5cdcfe7d95ac55b268cb508dddc1562ee06ec324098796d0ad736ad668949689)
As you can see, the figures are placed side-by-side. I would like to put each figure on a separate page.
*Things I've tried which don't work:*
- using the `multi=true` option in the `standalone` class
- using other document classes (e.g., `article`, `slides`, `letter`)
*Things which might be possible, but I don't know how to do:*
- inserting a MetaPost command to start in new page in between `endfig;` and `beginfig(2);`
- Inserting a TeX command to start a new page in between `endfig;` and `beginfig(2);`. I think this would require somehow temporarily exiting the mplibcode environment, because that environment is intended for MetaPost code.
*Note:* I don't want to do this by wrapping each figure in its own `mplibcode` environment, because then my variables from Figure 1 will not be accessible in Figure 2.
**How do I place each figure on a separate page?**
Top Answer
samcarter
> Note: I don’t want to do this by wrapping each figure in its own mplibcode environment, because then my variables from Figure 1 will not be accessible in Figure 2.
It seems that one can avoid this problem with `\mplibcodeinherit{enable}`:
```
% !TeX TS-program = lualatex
\documentclass[multi=mplibcode]{standalone}
\usepackage{luamplib}
\mplibcodeinherit{enable}
\begin{document}
\begin{mplibcode}
beginfig(1);
foo := 25;
draw fullcircle scaled foo;
endfig;
\end{mplibcode}
\begin{mplibcode}
beginfig(2);
draw fullcircle scaled foo withcolor red;
endfig;
\end{mplibcode}
\end{document}
```
Answer #2
Trevor
I figured out another solution myself. You can use MetaPost's `verbatimtex ... etex` function to insert Tex commands within MetaPost. So I added the following line in between `endfig;` and `beginfig(2);`
```
verbatimtex \newpage etex;
```
This solution works with the `standalone` package with the `multi=true` option, but it leaves a lot of space around the figures, and chopped off some of the top of my figures, even after adding a border with the `border` option. I had more success using the `article` class along with `\pagenumbering{gobble}` to suppress the page numbers.
Since this method leaves a lot of space around the figures, and doesn't seem to work with the `standalone` package, I prefer the answer from @samcarter. But maybe someone knows how to improve it.