I am trying to compile tree diagrams using the mptrees package (I like this) with LuaLaTeX
and luamplib
. On TeX Stack Exchange, I found only one question on this topic,
background color with \mpcolor
but it does not clarify what minimal code is required to compile the drawings of mptrees
package to compile correctly.
I have downloaded the mptrees
package's ZIP file and I am trying to understand what to add or remove to the following code to get the tree diagrams to compile successfully, starting from:
\documentclass[10pt]{article}
\begin{document}
\mplibforcehmode
\begin{exampleblock}{}\centering
\extractcolorspecs{block body example.bg}\modelcmd\colorcmd
\begin{mplibcode}
input mptrees;
beginfig(1)
dirtree:=-90;
typeprob:=2;
background:=(\colorcmd);
draw tree[1][1](1.25cm,5cm)("P","$\frac{1}{2}$","F","$\frac{1}{2}$");
draw tree[2][1](1.25cm,1.5cm)("R","$\frac{1}{5}$","B","$\frac{1}{5}$","N","$\frac{3}{5}$");
draw tree[2][2](1.25cm,1.5cm)("R","$\frac{1}{5}$","B","$\frac{1}{5}$","N","$\frac{3}{5}$");
endfig;
\end{mplibcode}
\end{exampleblock}
\end{document}
Hence:
What is the minimal working example (MWE) to get the mptrees
drawings to compile?
Any guidance or example codes would be greatly appreciated.
\mplibforcehmode
norexampleblock
are mentioned in the mptrees manual./usr/local/texlive/2025/texmf-dist/doc/metapost/mptrees/mptrees-doc.tex
in texlive and will be somewhere similar in miktex