-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Nested mplibcode environments? #63
Comments
Thanks for the report. |
Since luamplib v2.20 (TeX Live 2019), which was a huge internal change from the previous version, the example code shown above does not work anymore. I am currently trying to tackle the issue once again, but no success yet. So let me suggest another solution: \documentclass{article}
\usepackage{luamplib}
\newbox\mympbox
\setbox\mympbox\hbox{%
\begin{mplibcode}
beginfig(1);
draw unitsquare scaled 4 withcolor .67 red;
endfig;
\end{mplibcode}}
\def\redbox{\ensuremath{\mathop{\copy\mympbox}}}
\begin{document}
% same as MWE
\end{document} Now that |
thanks for the work around -- and glad to know you are still trying to tackle the issue. |
With recent version of luamplib, independent mplib instances can coexist with each other, running side by side. diff --git a/bug63ori.tex b/bug63.tex
index 1423e12..222a249 100644
--- a/bug63ori.tex
+++ b/bug63.tex
@@ -1,6 +1,6 @@
\documentclass{article}
\usepackage{luamplib}
-\newcommand{\redbox}{\ensuremath{\mathop{\begin{mplibcode}beginfig(1);draw unitsquare
+\newcommand{\redbox}{\ensuremath{\mathop{\begin{mplibcode}[nested]beginfig(1);draw unitsquare
scaled 4 withcolor .67 red;endfig;\end{mplibcode}}}}
\begin{document}
\noindent |
yes, looks good to me too. Many thanks. |
With just released version 2.34.1, which will be distributed via TeX Live tomorrow, we can obtain the same result very efficiently. \begingroup
\setbox0=\hbox{%
\begin{mplibcode}
beginfig(1);
draw unitsquare scaled 4
asgroup "" withgroupname "redbox"
withcolor .67red;
endfig;
\end{mplibcode}%
}
\endgroup
\newcommand{\redbox}{\ensuremath{\mathop{\usemplibgroup{redbox}}}} Of course, box 0 will be discarded after Even if the redbox is used hundreds times, PDF file size will remain quite small. Rather than replicating the same drawing code hundreds times, |
I'm trying to use luamplib to define a new symbol, and it works ok in normal math formulas, but I've run into a problem when I try to use it in a formula inside a label in another
mplibcode
environment. Here's my example that shows the problem.In the last math display the whole mplibcode picture is being replaced by the symbol.
The text was updated successfully, but these errors were encountered: